Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
<dominikh>
well, a activesupport thing, not a rails thing.
<deryldoucette>
actually i personally kind of like that oyu can do 1.week or 1.week_ago or something similar.
<deryldoucette>
makes it read a bit better if nothing else.
nobitanobi has joined #ruby
v0n has joined #ruby
axl_ has joined #ruby
macmartine has joined #ruby
ascarter has joined #ruby
thomd has joined #ruby
jon8 has joined #ruby
bglusman has joined #ruby
<kandinski>
just so I can google for it more easily, what is ruby for what in python we call defaultdicts?
<KnightWhoSaysNi>
kandinski: I dont know that in python, so care to explain what you are looking for?
<kandinski>
a hash or dict that returns a default value for keys not yet set
strnx has joined #ruby
<KnightWhoSaysNi>
kandinski: just use the normal hash, and set the default value
<KnightWhoSaysNi>
kandinski: documentation is your friend
<kandinski>
oh, right
akem has joined #ruby
<kandinski>
yeah, trying to fly by google
Hanmac has joined #ruby
<KnightWhoSaysNi>
kandinski: then flying by google, google for this: rdoc hash
<kandinski>
ta
<KnightWhoSaysNi>
kandinski: look for default there. you'll find it
<kandinski>
default
<kandinski>
oops
bwlang has joined #ruby
BrokenCog has joined #ruby
nari has joined #ruby
sbanwart has joined #ruby
ceej_ has joined #ruby
burns180_ has joined #ruby
ceej has joined #ruby
lkba has joined #ruby
shevy has joined #ruby
kf8a has joined #ruby
Targen has joined #ruby
robertjpayne has joined #ruby
<delinquentme>
where can I go to look @ the core ruby code running behind the power operator " ** " ?
luxurymode has joined #ruby
randym_ has joined #ruby
<banister`sleep>
delinquentme: in pry
<banister`sleep>
delinquentme: just type: show-method Fixnum#**
<delinquentme>
banister`sleep, i managed to find it ... its all C code though right?
<banister`sleep>
i mean, it looks that way doesnt it? :)
philcrissman|afk has joined #ruby
<delinquentme>
yeah I was just having a discussion how to operate in log space in ruby .. i thought I'd get a hack and look @ the source but didn't turn out like that
<banister`sleep>
it looks lke most of that code is just looking for cases it can optimize to integer operatios
<banister`sleep>
operations
<davidcelis>
isn't all of ruby C code
<banister`sleep>
davidcelis: core is, not stdlib
<davidcelis>
thats what i meant
<banister`sleep>
and even some core is ruby too i think
<davidcelis>
i'd be interested to know what
<davidcelis>
makes sense for stdlib to be ruby, but not sure what in Core would be ruby
JonnieCache has joined #ruby
<nobitanobi>
I have a StringIO object (file_io) which I have written some XLS. When I do file_io.data, if there are big amounts of lines, they won't get written. However if I do file_io.string, I get the expected results. Why is that?
<nobitanobi>
I can't find which "method" is "string" in StringIO class
<deryldoucette>
this will probably sound stupid but oh well. what is core and stdlib? isn't stdlib of something the core of it?
luckyruby has joined #ruby
<banister`sleep>
deryldoucette: core are things you dont have to require to use
minijupe has joined #ruby
<banister`sleep>
stdlib are things that you have to require to use but which you dont have to install separately (as a gem), it comes with ruby
davidpk has joined #ruby
<deryldoucette>
ahhhh. ok. thanks
sbanwart has joined #ruby
thone has joined #ruby
<banister`sleep>
so, Enumerable is core, OpenStruct is stdlib
<davidcelis>
Set is stdlib
<deryldoucette>
what is the defined reason for providing it like that?
burns180 has joined #ruby
<davidcelis>
deryldoucette: they're classes that aren't really "frequently" used
<deryldoucette>
the stdlib stuff?
<davidcelis>
so it makes more sense to have to require them than to include them by default
<davidcelis>
yes
<A124>
Anyway.. what is the Set good for?
<deryldoucette>
got ya
<A124>
I had slower results than with array.
<deryldoucette>
thanks for that
<banisterfiend>
A124: because Set is written in ruby
<davidcelis>
A124: ^
<banisterfiend>
and it's not about performance it's about behaviour
<davidcelis>
A124: you use Set when you want set behavior
apok has joined #ruby
<A124>
Set behavior?
<davidcelis>
A124: if you're doing more advanced set math operations, you'd want to use Set. of course, you could always just interface with Redis and do your set shit there (which is what I do)
<A124>
Can you explain a little or rfer me please?
<deryldoucette>
and Set can be any 'type'?
<banisterfiend>
A124: a set is a common datastructure in compsci
<petercooper>
Set's slower than array because it's written in pure Ruby and just uses a hash behind the scenes.
<A124>
davidcelis: Thanky ou.
<A124>
Yes. I understand that
<davidcelis>
A124: but if the functionality you're looking for is set math, you WOULD want to use Set
<davidcelis>
and not an Array
Mac has joined #ruby
<petercooper>
If you really wanted to, and had some nice tests backing it up, you could jerry rig /some/ equivalent behavior with arrays that use Array#uniq all over the place.. (messy but hey)
<A124>
petercooper: Ah. Thanks.. That is a good to know.
<davidcelis>
like banisterfiend said earlier, it's about functionality not performance
havenn has joined #ruby
<banisterfiend>
well you could have both if you really wanted :)
<pietr0>
you could try and implement YourOwnSet that uses Array instead of Hash and see if it is faster than Set too :P
<banisterfiend>
but people dont appear to really want, afaik
<davidcelis>
banisterfiend: that's why i use Redis for my set shit :)
<petercooper>
For example, Array#|'s documentation even says "set union"
<petercooper>
(since it removes duplicates.. but that's not a true property of an array, so be warned)
<A124>
Ah. yes. Exactly.
<A124>
In my partucular case, although working in a Set like data, Arrays worked for me.
<deryldoucette>
that is slightly confusing to me. if set is a hash, and i was taught hashes have keys and values (obviously), how is it storing them since there are no key/value pairs?
<A124>
Is there any array#union method that does not remove duplicates?
<deryldoucette>
or can you point me at a more detailed tutorial on it?
<petercooper>
@hash[o] = true
<petercooper>
(that's straight from set.rb)
<deryldoucette>
s1.keys and s1.values (using the example from the ri page) give errors
<davidcelis>
deryldoucette: well they abstract the hah out
<davidcelis>
deryldoucette: it just uses a hash on the back-end of Set; you're not supposed to know about that when using it, though
<petercooper>
be careful though.. once you start reading the MRI source and you get hooked, you will lose the will to live very quickly
<davidcelis>
you can't treat a Set like a hash for that reason
<deryldoucette>
petercooper: hahah
<petercooper>
and turn into brixen
<deryldoucette>
no thank you
tomzx has joined #ruby
<deryldoucette>
petercooper: hehe that was fast on the git link. i was just starting to google for it when you hit me with it. quickee :)
Norrin has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
<petercooper>
brixen turned me onto some "fun" reading.. the test/ruby/ folder in the MRI repo
<deryldoucette>
davidcelis: i see what you mean
<A124>
Is there Array#union, which does _not_ remove duplicates?
<deryldoucette>
i really should start reading through the source of ruby. i tried once before when i was *really* new to ruby and got lost because i wasn't sure *where* to start.
<deryldoucette>
still not entirely sure
<petercooper>
The stdlib is, IMHO, the most useful and 'easiest' place to start.
<davidcelis>
definitely
<davidcelis>
since it's ruby code
<A124>
Agreed
<petercooper>
Since it's all in Ruby and you probably know half of the libraries already.
<davidcelis>
the ruby core source can be difficult to parse at first because it's mostly C
<davidcelis>
but if you're comfortable with C, you can dive into it
<deryldoucette>
been years since i've touched c but i can *fairly* well grok it.
<deryldoucette>
i'll start with stdlib though
<petercooper>
it's.. a rather flavored sort of C but it's reasonably easy to read.
<petercooper>
I'd argue, though, you'll learn more about the quirks of MRI rather than anything inherently interesting about Ruby as a language that way.
<banisterfiend>
rbx source is nice to explore in comparison
mikepack has joined #ruby
<deryldoucette>
yeah the language is more important to me than any single implementation
sbanwart has joined #ruby
<petercooper>
But it's a handy exercise when you notice certain weird behaviors and want to drill down into why they happened (such as the recent change of #responds_to? returning false for protected methods).
<deryldoucette>
just trying to learn a bit more
<petercooper>
respond_to even, I'm *always* making that mistake in code :)
albemuth has joined #ruby
<banisterfiend>
petercooper: you mean it used to return true for both public and protected but only false for private?
<petercooper>
yes (unless you pass true as the second argument)
nimred has joined #ruby
<banisterfiend>
yeah you're right
<petercooper>
essentially, the second argument changed from being 'include private' to 'include private and protected'
<banisterfiend>
haha i didnt even know about the second parameter
<banisterfiend>
i assume method_defined? has a second param too
<petercooper>
I had to look that up, but no it doesn't.
<banisterfiend>
hmm, seems method_defined? worked with public/protected anyway
<petercooper>
"Public and protected methods are matched."
<deryldoucette>
i just want to make less mistakes, learn a bit more of the implementation, and i've found the docs can be rather confusing especially since the ruby-doc site doesn't do 'go to source' for the classes.
<petercooper>
I think that's because if you're working with a class or module anyway, you're not really interrogating behavior but mere existence.
btfriar has joined #ruby
<kandinski>
I mean I want my default value to be a new empty lit each time
burns180_ has joined #ruby
<petercooper>
Ye need a block to do that
<petercooper>
Hash.new { Array.new }
<A124>
Sorry for people that see that again:
<kandinski>
petercooper: thanks
<petercooper>
The reason is that Array.new *immediately* evaluates in Hash.new(Array.new)
<A124>
Is there a way to do "file_1 - (file_2 - (file_1 & file_2))" more rubost? (all types are array
<petercooper>
Indeed, it evaluates before Hash.new.. so you end up with Hash.new(A SINGLE SPECIFIC ARRAY OBJECT)
<petercooper>
And that's important because most objects are mutable and can be changed in place.
<kandinski>
it returns a reference to one array multiple times, instead of returning multiple new empty arrays
<A124>
petercooper: Thank you kindly for making that selfevident. Thanks.
<petercooper>
Whereas Hash.new(0) is fine
<A124>
Can you please explain why is the behaviour like so?
<petercooper>
Well, consider the same thing again.. you end up with a hash where every element is 0.
<petercooper>
But then you do something like h[:a] += 1
<kandinski>
0 is not mutable
<petercooper>
doing that *creates* an all new object and places it into h[:a] .. 0 to 1.
akem has joined #ruby
<petercooper>
because as kandinski says, fixnums are immutable
<A124>
petercooper: So basicaly, anything, which is not an object, that can be changed "within" is ok? Right?
<petercooper>
I think you have an understanding of it but that's really true
<kandinski>
I have been noticing that ruby is much more orthogonal than Python, and this is the first example of nonorthogonality I have found
<banisterfiend>
A124: everything is an object :)
<petercooper>
not really true, even
<petercooper>
0 is still an object, just an immutable (can't be changed) 'value object'
<petercooper>
whereas [] and [1,2,3] MAY be the same object
<petercooper>
0 and 1 are NEVER the same object
<A124>
banisterfiend: I know that. I was wondering if someone would not misinterpret it
<kandinski>
having to guard for mutable vs nonmutable objects as default values in hashes
<A124>
>>>> which is not an object, that can be changed "within"
<kandinski>
petercooper: thanks for the explanation
<A124>
This is one item
<kandinski>
A124 is german
<banisterfiend>
ah, bad comma :)
<A124>
No, I'm Czech xD
<A124>
Sorry xD
<petercooper>
dobry den
delinquentme has joined #ruby
<A124>
I do this mistake, as we would use comma, so it's sometimes automatically
<A124>
AH, nice day to you too!
<petercooper>
I went to EURUKO in 2008
<petercooper>
and learnt just that
<A124>
Ah. But in case of greetings, we do care about capitalization. As it is a greeting.
<delinquentme>
hey all .. so I just had an interview and was given an interesting operation .. basically come up with a novel way to run power operations ... I figured I'd do some meta programming and basically edit a string like this ... eval = "a*a*a*a*a*a*a*a*a*a*a*a*1" then evaluate it for whatever value a equals ... so the question is .. what is the best way to translate this from a mutable string .. into something that I can run that ope
<delinquentme>
ration on?
<A124>
(Not inside a sentence)
<delinquentme>
eval(eval)
<delinquentme>
yusss
<banisterfiend>
delinquentme: there needs to be more information than 'come up with a novel way to run power operations' IMO
<delinquentme>
banisterfiend, i think i figured it out :D
<banisterfiend>
delinquentme: i really dont think string evals was what they had in mind
gentz has joined #ruby
<petercooper>
maybe it was tumblr hiring for sysadmins
<A124>
petercooper: So, if may I ask it again, if the object is identified by self and not by data it contains, it is immutable, right?
<petercooper>
Hmm... without committing myself here, I don't /think/ that's strictly true BUT you should treat value objects as immutable, as least.
genivf has joined #ruby
<A124>
*and not by identifier which has nothing to do with the data itself
<A124>
OK, thank you a lot :)
<petercooper>
I can't immediately thing of any value objects in Ruby that are mutable but that doesn't mean there aren't any.
<banisterfiend>
A124: string is identified by self? :)
<banisterfiend>
yet it's mutable
<A124>
banisterfiend: Ah, thanks for seeing this for me. That's true
burns180 has joined #ruby
<petercooper>
That's true, though I don't consider strings a value object in Ruby for that reason. So maybe I'm stumbling into a fallacy of equating immutability and value objects ;-)
<A124>
But I would count it immutable by my logic, so it's kind of mystery to me. That's why I asked in the first place
<banisterfiend>
petercooper: well if by value object you mean 'immediate' objects then you're right
<petercooper>
I think that's where I'm headed
QaDeS_ has joined #ruby
<A124>
So.. How can I tell what is and what is not immutable?
<banisterfiend>
A124: numerics are immutable, but not all of them are immediates
<banisterfiend>
floats aren't immediates for example, but are immutable
<A124>
Google tells me only what they are, not how to know if they (objects) are.
ZachBeta has joined #ruby
<petercooper>
a really ugly stab in the dark (not that you should ever get to this)
<petercooper>
begin; obj.dup rescue TypeError; false; end
liluo has joined #ruby
<delinquentme>
banisterfiend, http://pastie.org/3530394 << if you were curious as to my mumblings :D
<banisterfiend>
delinquentme: yeah, but i really dont think that's what they wnated :)
<banisterfiend>
and if they did, then they're kind of retarded
<banisterfiend>
IMO :)
<petercooper>
maybe they're a Rails shop
<A124>
petercooper: Oh. Thanks. That's the ruby way. Is there any "human" way also?
<A124>
And your stup does return false for a string
<petercooper>
that's because strings are mutable
<delinquentme>
banisterfiend, lol
<petercooper>
I was answering the "How can I tell what is and what is not immutable?" bit only.. with a working but less than ideal answer.
<delinquentme>
banisterfiend, lemme see your version
<banisterfiend>
delinquentme: i dont even know the question, "write a novel way of running to the power of" doesn't seem like a complete question to me
<A124>
petercooper: I see your "dup" point
<A124>
But the stub returns false always!
ilyam has joined #ruby
<petercooper>
ah, you want me to actually test it? man! ;-)
<banisterfiend>
delinquentme: also your method doesnt handle fractional powers
<petercooper>
begin; obj.dup; rescue TypeError; false; end
<petercooper>
I missed a semi-colon which tied the rescue to the dup only, sorry.
<petercooper>
when in doubt, semicolons EVERYPLACE ;-)
<A124>
petercooper: Yes. Thank you.. I already figured that when I write it by hand it's ok. You found the problem ;) Thanks.
<sag47>
I've never developed in ruby before but I know programming concepts so seeing samples I could probably do it.
<sag47>
I'm not able to use traditional tools like ldd or strace with this so I'm not sure how to tackle the error
<sag47>
googling also did not turn up much
<banisterfiend>
petercooper: you can't dup threads either, and i guess they're 'mutable' in a sense :)
<petercooper>
oh snap
ocketr has joined #ruby
<sag47>
I'd be obliged if someone could help
LowKey has joined #ruby
gentz has joined #ruby
seanstickle has joined #ruby
eko has joined #ruby
eko has joined #ruby
Guest82554 has joined #ruby
phantasm66 has joined #ruby
phantasm66 has joined #ruby
shtirlic has joined #ruby
burns180 has joined #ruby
cpruitt has joined #ruby
liluo has joined #ruby
albemuth has joined #ruby
emnl has joined #ruby
looopy has joined #ruby
davidcelis has joined #ruby
kah has joined #ruby
bglusman has joined #ruby
randym_ has joined #ruby
emnl has joined #ruby
akem has joined #ruby
emnl has joined #ruby
gregor has joined #ruby
cloke has joined #ruby
<A124>
banisterfiend: Agreed. Thanks for pointing that out. Could save me troubles later ^^
axl_ has joined #ruby
godfrey999 has joined #ruby
yoklov_ has joined #ruby
choffstein has joined #ruby
akem has joined #ruby
sacarlson has joined #ruby
bglusman has joined #ruby
banister_ has joined #ruby
boodle has joined #ruby
krz has joined #ruby
emnl has joined #ruby
CheeToS has joined #ruby
banisterfiend has joined #ruby
havenn has joined #ruby
robertjpayne has joined #ruby
libertyprime has joined #ruby
Temp has joined #ruby
baroquebobcat has joined #ruby
hadees has joined #ruby
axl_ has joined #ruby
moshee has joined #ruby
luxurymode has joined #ruby
libertyp1ime has joined #ruby
`brendan has joined #ruby
wmoxam has joined #ruby
godfrey999 has quit [#ruby]
mosheee has joined #ruby
Hanmac has joined #ruby
nobitanobi has quit [#ruby]
Synthead has joined #ruby
moshee has joined #ruby
havenn has joined #ruby
<robertjpayne>
Ruby docs state you should override eql? in a subclass, is there a different method ( besides hash ) to ensure == results in object equality?
nvez has joined #ruby
nvez has joined #ruby
<petercooper>
robertjpayne: equals?
araujo has joined #ruby
<robertjpayne>
petercooper: isn't equals? synonemous with eql?
<petercooper>
ddoh, I meant equal?
<petercooper>
no, 1,2,3].equal?([1,2,3]) # => false
<petercooper>
[1,2,3].eql?([1,2,3]) # => true
banisterfiend has joined #ruby
<robertjpayne>
thanks :)
pdtpatr1ck has joined #ruby
ben_alman has joined #ruby
nvez_ has joined #ruby
havenn has joined #ruby
wmoxam has joined #ruby
flingbob has joined #ruby
<robertjpayne>
petercooper: hmm, seems uniq! uses eql? vs equal?
Faris has quit [#ruby]
burns___ has joined #ruby
<petercooper>
Yes
<robertjpayne>
petercooper: alright then I will need to override eql?, seems odd the documentation recommends against it? But I've seen it overriden many of times
<petercooper>
bear in mind you can override == as well
MrGando has joined #ruby
<petercooper>
so if you wanted you could redefine == to do object (id) equality
<petercooper>
and eql? to do whatever else you want
<petercooper>
against convention but doable
sacarlson has joined #ruby
<robertjpayne>
cool thanks
nricciar_ has joined #ruby
minijupe has joined #ruby
cbuxton has joined #ruby
stringoO has joined #ruby
carlyle has joined #ruby
kah1 has joined #ruby
havenn has joined #ruby
burns180 has joined #ruby
Quadlex has joined #ruby
phantasm66 has joined #ruby
banister_ has joined #ruby
wefawa has joined #ruby
al3xnull has joined #ruby
<wefawa>
OMFG: Do you people think of mixings when you hear "Composition over inheritance"?
pu22l3r has joined #ruby
<banister_>
wefawa: do u
pu22l3r has joined #ruby
btfriar has joined #ruby
<wefawa>
banister_: certanly not, but I'm seing a video from an online curse, and it said that... And I wanted to bang my head against the wall...
<kandinski>
so, if I am looking into an Array of Arrays of arrays recursively, what's the ruby way to stop recursing when I hit a non-array? I am doing checking a certain element is a string, but that's a non-general non-duck way
<wefawa>
kandinski: check if it's a simple tournament of 1v1
<kandinski>
wefawa: yes, I am doing saas-class, you got me there
<wefawa>
kandinski: don't belive everything that course says -_-
tomasz has joined #ruby
<kandinski>
but that's exactly what I am doing; the way I know it's 1v1 is by checking a certain member is not a list
<kandinski>
sorry, Array
<wefawa>
kandinski: I solved it by checking if it was a string or not
<kandinski>
wefawa: that's what I am doing
<kandinski>
but it feels dirty and non-ducky
adamkittelson has joined #ruby
mfridh has joined #ruby
<wefawa>
kandinski: so?
<kandinski>
why not learn good form?
<kandinski>
first you get the code working, then you make it nice
<wefawa>
kandinski: Because representing a torunament with an arrays of arrays is not good form...
<kandinski>
you can only control what you do, not what others do
adamjleonard has joined #ruby
<wefawa>
kandinski: I know, but I can't solve the bad forms of others...
tyoc213 has joined #ruby
<tyoc213>
if I have a = [1,2,3] and b = %[a b c] how I merge them to have things like ["1xa", "2xb", "3xc"] including x
<wefawa>
you need a zip...
kajisap has joined #ruby
<tyoc213>
what will happen if because x is know always, then I dont have an array?
<tyoc213>
I only have 1 instance of x
havenn has joined #ruby
sdwrage has joined #ruby
<wefawa>
tyoc213: you can surely copy it
blueadept has joined #ruby
banisterfiend has joined #ruby
deryldoucette has joined #ruby
banister_ has joined #ruby
<tyoc213>
it is a string... just tryied "x"*5 and that to_enum tought it return an each function String doesnt has each
wookiehangover has joined #ruby
munx has joined #ruby
baroquebobcat has joined #ruby
SegFault1X has joined #ruby
radic_ has joined #ruby
csprite_ has joined #ruby
ilyam has joined #ruby
csprite has joined #ruby
cout has joined #ruby
ghanima has joined #ruby
wefawa has quit [#ruby]
<kandinski>
petercooper: you told me earlier about implementing memoization as an exercise?
gokul has joined #ruby
<kandinski>
exercise five of this week's saas HW is implementing a history mechanism for instance variables
albemuth has joined #ruby
<kandinski>
"ugly but fun" indeed
yoklov has joined #ruby
<heftig>
kandinski: queue.
shadoi has joined #ruby
burns180 has joined #ruby
libertyp1ime has joined #ruby
k-man has joined #ruby
baroquebobcat has joined #ruby
<k-man>
when i add an element to a list like this: configure_args << 'some string' how do i prevent it from having the space escaped with \?
rohit has joined #ruby
cableray_ has joined #ruby
Squarism has joined #ruby
<k-man>
nm, worked it out
k-man has quit ["WeeChat 0.3.7"]
scalebyte has joined #ruby
<scalebyte>
How can I make this short?
<scalebyte>
p == @user.about_me if !@user.about_me.empty?
rippa has joined #ruby
<rohit>
p == ? or p =
<wallerdev>
is there a context to that?
<wallerdev>
you're comparing them if its not empty?
<scalebyte>
no assigning to p
<scalebyte>
if @user.about me is not empty
<wallerdev>
oh you've got an extra =
<scalebyte>
wallerdev: ^^
<rohit>
p = @user.about_me unless @user.about_me.empty?
<wallerdev>
you could do p = @user.about_me || p if you're using empty just for nil
<scalebyte>
wallerdev: ok thanks
<wallerdev>
otherwise what rohit said will work fine, although it's longer lol
<rohit>
scalebyte: If this is Rails by any chance you might be able to do p = @user.about_me.presence
<wallerdev>
what's presence do in rails?
<rohit>
I'd go with wallerdev too because unless can be confusing sometimes
<bean_dharma>
Hi all, I have a ircbot written with Cinch. I would like for it to parse this XML file ( api.own3d.tv/liveCheck.php?live_id=153518 ) on a certain trigger. Is REXML ( specifically this tutorial http://www.germane-software.com/software/rexml/docs/tutorial.html ) what I should follow, or is there a better/another way I can accomplish this?
<senthil>
the one thing i don't like with this approach is how @log changes from method to method, in the other approach i'm using the output from the various methods, not @log itself
<banisterfiend>
senthil: hey, can u confirm 0.9.8.4 fixes two of your bugs (the one we didnt fix was hist --replay)
<senthil>
TTilus: def remove_tabs(log); log...; log; end ?
<TTilus>
senthil: think about it this way: if you'd ever need to somehow rework your class or somebody else had to figure out where that commit list came from, how'd you do that? with side-effects approach you have nothing but attr_reader to start with, then you need to go find all the @commits uses and you'll see you actually need to look for @log uses ... and boy you have them and no way to directly tell you during your tracing that in what order are the @log modific
<TTilus>
senthil: def remove_tabs(str); str.gsub(/\t/, " "); end
zakwilson_ has joined #ruby
<senthil>
TTilus: hmm, i'm not arguing against that
<TTilus>
senthil: since your class is so small, this is not that big an issue at all
<senthil>
TTilus: i'm just trying to learn the OOP way and how rubyists would do it
<shevy>
senthil rubyists do things a little bit differently even from among other OOP languages
ryanf has joined #ruby
<shevy>
I think what ruby is very characteristic of, if you write a lot of code, is that
<shevy>
you tend to use many small methods
<TTilus>
senthil: but since you brought the subject up and was dissatisfied with your current approach for the _same_ reason i was, i did a version of the class not having the issue =D
<senthil>
TTilus: i appreciate that, thx :)
LMolr has joined #ruby
eltigre has joined #ruby
Spockz` has joined #ruby
<TTilus>
besides what shevy mentioned, ruby codebases tend to have a dash of functional style mixed in the oop
<eltigre>
hey, I'd like to get the value of a certain attribute inside a dynamically added method, but I only have that attribute's name as a dynamically constructed name...
mafolz has joined #ruby
<TTilus>
eltigre: foo.send(attribute_name)
<eltigre>
ah
<TTilus>
eltigre: thats what u asked for?
<eltigre>
thanks
<eltigre>
maybe
<TTilus>
eltigre: if it wasnt, please provide some code we can look at
hubub_ has joined #ruby
<TTilus>
senthil: ...also rubyists are in love with dsls
<senthil>
TTilus: its very handy
nachtwandler has joined #ruby
ph^ has joined #ruby
needashave has joined #ruby
Hanmac1 has joined #ruby
<eltigre>
and how do I set an instance variable inside it's setter?
<eltigre>
like normally with @attr_name, but I have attr_name as a string
<smooth_penguin>
its supposed to read a file backwards
<smooth_penguin>
I couldnt find anything that did it already which reading the whole file from the top
<smooth_penguin>
s/which/without
fowl has joined #ruby
rohit has joined #ruby
etehtsea has joined #ruby
dhruvasagar has joined #ruby
<arturaz>
smooth_penguin, should work
sriprasanna has joined #ruby
LowKey has joined #ruby
<Companion>
smooth_penguin, sounds like a smooth criminal to me;o
<smooth_penguin>
heh :)
tatsuya_o has joined #ruby
<dr_bob>
smooth_penguin: the nil check is superflous
<banisterfiend>
dr_bob: hey robert what's up
<dr_bob>
hi banisterfiend! What comes up, must go down.
justinmcp has joined #ruby
<banisterfiend>
dr_bob: that's what she said
seoaqua has joined #ruby
<shevy>
didn't she ask "when will it come up"
tk__ has joined #ruby
<banisterfiend>
shevy: haha, you're such a naughty man shevy!
<shevy>
I swear
<shevy>
dr_bob started it :(
<shevy>
and you only made it worse
* dr_bob
points at banisterfiend
canton7 has joined #ruby
jakky has joined #ruby
Danielpk has joined #ruby
twqla has joined #ruby
tayy has joined #ruby
TaTonka has joined #ruby
stefanp has joined #ruby
<stefanp>
hi.
<smooth_penguin>
dr_bob: yep, ill get rid of it
<stefanp>
Code coverage is supposed to measure what lines actually get executed, right?
<heftig>
yes
<stefanp>
I just plugged simplecov into a project and it repoted everything covered even though the code in question was only required but not executed. Is that normal?
<banisterfiend>
heftig: hey heft
<heftig>
hi
ninegrid has joined #ruby
<banisterfiend>
heftig: working on anything interesting
<banisterfiend>
?
<heftig>
no
philcrissman|afk has joined #ruby
<banisterfiend>
heftig: can i give u something interesting to work on
<heftig>
maybe
<banisterfiend>
ok one sec
burns180_ has joined #ruby
ikaros has joined #ruby
<heftig>
stefanp: basically, requiring a file executes the code within
<heftig>
now code can be made of things that are not executed immediately, such as methods
<banisterfiend>
heftig: basically: binding.eval("__FILE__") is broken on jruby
<stefanp>
heftig: that is what i wanted, i wanted to see what methods get actually executed, not just required and loaded, but I got the latter.
<dr_bob>
stefanp: you could use set_trace_func to get more interesring information
<banisterfiend>
heftig: but we can probably just extract the file from the first element in _pry_.backtrace, which should be the immediate caller of `binding.pry`
smooth_penguin has joined #ruby
<banisterfiend>
dr_bob: are you familiar with LD_PRELOAD ?
<dr_bob>
nope
<banisterfiend>
anyone here familiar with LD_PRELOAD ?
<shevy>
"How does it perform this magic? It is accomplished using the LD_PRELOAD method, which preloads a shared library before installation using the environment variable LD_PRELOAD. During installation, this library catches the system calls that cause filesystem alterations (such as open, link, rename, ...), and logs the created files."
<shevy>
oh dang I forgot
<shevy>
it's actually C++ in .cc files :(
<shevy>
but it is still cool
<banisterfiend>
shevy: hehe i like it
<banisterfiend>
cool idea
kidoz has joined #ruby
<shevy>
it even works! I used paco for a while, gpaco has a little gtk interface and you can create packages of programs that you compiled
<banisterfiend>
yeah LD_PRELOAD is the shit
<banisterfiend>
i just wish it worked properly for me
berserkr has joined #ruby
<heftig>
banisterfiend: pulling something out of a string like that sounds like a horrible hack
<shevy>
that is the foundation of UNIX
<banisterfiend>
heftig: i know, but JRuby's Binding object is broken, so it's all we have
<shevy>
hack on hack upon hack
<shevy>
until the hack becomes to useful that it becomes a genius idea
Faris has joined #ruby
<banisterfiend>
shevy: fowl said you've changed since you disappeared to play skyrim
<shevy>
but if I depend on awk I can just as well use ruby too :P
BrianE has joined #ruby
dhruvasagar has joined #ruby
<heftig>
shevy: IFS=';' read -a a <<<'one;two;three and four'; echo ${a[@]}
<heftig>
much better
<heftig>
no awk, and doesn't fail with whitespace either
<shevy>
hmm
MrGando has joined #ruby
francisfish has joined #ruby
hubub has joined #ruby
mdw_ has joined #ruby
mdw__ has joined #ruby
justinmcp has joined #ruby
InBar has joined #ruby
eldariof has joined #ruby
MrGando has joined #ruby
JonnieCache has joined #ruby
erenrich has joined #ruby
mdw has joined #ruby
hubub has joined #ruby
<stanman246>
how do you guys test authenticate user's pages?
conor_ireland has joined #ruby
fr0gprince_mac has joined #ruby
geofridh has joined #ruby
ksinkar_ has joined #ruby
Barakas has joined #ruby
mklappstuhl has joined #ruby
iocor has joined #ruby
geofridh has joined #ruby
S2kx has joined #ruby
<JonnieCache>
stanman: depends on the auth framework
chalky has joined #ruby
<JonnieCache>
but generally you have to stub some part of the auth system
ksinkar__ has joined #ruby
Bish_ has joined #ruby
jimmyy111 has joined #ruby
<shevy>
stab?
workmad3 has joined #ruby
<JonnieCache>
stub
<JonnieCache>
clean your monitor
<shevy>
here I already hoped I could stab something :(
dhruvasagar has joined #ruby
ksinkar has joined #ruby
geek_ has joined #ruby
randym_ has joined #ruby
MMSequeira has joined #ruby
nanderoo has joined #ruby
ksinkar_ has joined #ruby
fearoffish has joined #ruby
aibo has joined #ruby
16WAAEE64 has joined #ruby
Geek has joined #ruby
stanman246 has joined #ruby
kidoz has joined #ruby
rippa has joined #ruby
mfridh has joined #ruby
sacarlson has joined #ruby
musl has joined #ruby
xpot-mobile has joined #ruby
musee has joined #ruby
yeggeps has joined #ruby
Vadim has joined #ruby
dubellz has joined #ruby
gogiel has joined #ruby
pielgrzym has joined #ruby
Emmanuel_Chanel has joined #ruby
ged has joined #ruby
iaj has joined #ruby
ePirat|off has joined #ruby
vereteran has joined #ruby
mxweas has joined #ruby
leex has joined #ruby
zaargy has joined #ruby
kapowaz has joined #ruby
fred has joined #ruby
smgt has joined #ruby
sixteneighty has joined #ruby
momo- has joined #ruby
Jelco has joined #ruby
__main__ has joined #ruby
ecolitan has joined #ruby
kW_ has joined #ruby
chalky has joined #ruby
mitchty_ has joined #ruby
regedarek has joined #ruby
libertyprime has joined #ruby
dubellz has joined #ruby
benvds has joined #ruby
ksinkar_ has joined #ruby
adamjleonard has joined #ruby
ksinkar__ has joined #ruby
chalky has joined #ruby
francisfish has joined #ruby
senny has joined #ruby
ksinkar__ has joined #ruby
cha1tanya has joined #ruby
chaitanya_ has joined #ruby
tweeKula has joined #ruby
lorandi has joined #ruby
LMolr has joined #ruby
nari has joined #ruby
looopy has joined #ruby
ksinkar has joined #ruby
liluo has joined #ruby
ksinkar_ has joined #ruby
xMKx has joined #ruby
emmanuelux has joined #ruby
banisterfiend has joined #ruby
pu22l3r has joined #ruby
ksinkar__ has joined #ruby
adman65 has joined #ruby
LMolr has joined #ruby
Prezioso has joined #ruby
ksinkar has joined #ruby
flingbob has joined #ruby
burns180 has joined #ruby
drake has joined #ruby
`brendan has joined #ruby
benvds has joined #ruby
t0lkman has joined #ruby
Rezwan has joined #ruby
ksinkar has joined #ruby
looopy has joined #ruby
<t0lkman>
Hello there, I have encounter an error on my OS X Lion: whenever I run rdoc, i get I can't deal with a socket ./Library/Application Support/Ubiquity/ubiquity.socket
<t0lkman>
Hello there, I have encounter an error on my OS X Lion - whenever I run rdoc I get follwoing: I can't deal with a socket ./Library/Application Support/Ubiquity/ubiquity.socket
<t0lkman>
if your are on OSX can you please try run rdoc and see what you get
ghostlines has joined #ruby
trivol has joined #ruby
stick has joined #ruby
dbgster has joined #ruby
ksinkar has joined #ruby
maltray has joined #ruby
andreime has joined #ruby
<maltray>
Hello guys, im trying to make a crawler for the twitter urls, thing is that most of them are redirected to t.co or some other URL shortner, the resp = Net::HTTP.get_response(URI.parse(@url)) function gives me: #<Net::HTTPMovedPermanently 301 Moved Permanently readbody=true>, any ideas?
<andreime>
hello! i am running rspec on a folder and tests are failing but when i run them on a file they all pass... any ideas why this is happening ?
<arturaz>
andreime, interdependent tests that mutate shared space
tatsuya_o has joined #ruby
bluOxigen has joined #ruby
flagg0204 has joined #ruby
<andreime>
arturaz: sounds nice, any ways of protecting/fixing this ?
<arturaz>
are you using fixtures?
sdwrage has joined #ruby
<arturaz>
for sample data?
<andreime>
arturaz: just some mocks and normal way of creating variables and checking them out
<andreime>
unfortunately this is a maintenance job, so I don't know all the tests, but I think mocks and stub is the only thing
<arturaz>
perhaps your mocks out of your test example scope?
<andreime>
i've just looked for fixtures and it seems there are some in this project
brjannc has joined #ruby
ksinkar_ has joined #ruby
<arturaz>
use factory_girl/blueprints instead of them
<arturaz>
and transactional fixtures
<arturaz>
so db state would be clean every time
<andreime>
for the tests that i am currently checking, there aren't any fixtures or mocks used
<arturaz>
anyway, tests usually fail in this way due to some shared state
<andreime>
aha, seems like a reasonable problem
<andreime>
pfff
<andreime>
:)
priteshjain has joined #ruby
Xerife has joined #ruby
ksinkar__ has joined #ruby
stick has quit ["Leaving"]
<andreime>
arturaz: is the fact that everybody is using before do ( not before(:all) do ) impacting on this?
<andreime>
possibly?
<arturaz>
before defaults to each IIRC
<andreime>
oh
<andreime>
ok
<andreime>
didn't knew that
<andreime>
i think i've got it
<andreime>
thanks for the help
emocakes has joined #ruby
<arturaz>
np :)
lorandi has joined #ruby
r126l has joined #ruby
jesly has joined #ruby
davidpk has joined #ruby
mdw has joined #ruby
Husel has joined #ruby
burns180 has joined #ruby
michaelh has joined #ruby
vmatiyko has joined #ruby
chalky has joined #ruby
ryanlabouve has joined #ruby
Jackneill has joined #ruby
<smooth_penguin>
hey in ruby 1.8.6 is there anyway to convert a string like "Mar 06 10:18:55" into epoch ?
cpruitt has joined #ruby
<smooth_penguin>
1.8.7 seems to have Time.parse
neurodrone has joined #ruby
neurodrone has joined #ruby
Sailias_ has joined #ruby
mdw_ has joined #ruby
tomzx has joined #ruby
tommyvyo has joined #ruby
chalky has joined #ruby
chalky has quit [#ruby]
dAnjou has joined #ruby
geekbri has joined #ruby
philcrissman has joined #ruby
burns180_ has joined #ruby
srp_ has joined #ruby
<dAnjou>
hi, i got this line in someone else's code and i'd like to change it: "$stdout << target.prepare![:build_number]". i want a new line at the end. what is a proper way? just ' << "\n"' at the end or am i running into trouble on different OS with this?
<dAnjou>
i'm don't know ruby very well
<dAnjou>
*I
fouriek has joined #ruby
Seisatsu has joined #ruby
priteshjain has joined #ruby
<zul__>
hi all
dv310p3r has joined #ruby
<zul__>
could anybody help me in a rake of a db (I'm using padrino) and I'm a newbie
wyhaines has joined #ruby
fouriek has joined #ruby
bnhymn has joined #ruby
<zul__>
is there anybody=
<zul__>
?
macmartine has joined #ruby
chalky has joined #ruby
<dAnjou>
zul__: i get ignored too o.O
<adamjleonard>
I have class FooBar with attr_accessors foo, bar. Can you do [foo, bar].any?(&:nil?)
chalky has joined #ruby
<arturaz>
adamjleonard, you should
bwlang has joined #ruby
<adamjleonard>
arturaz: Thank you sir
<arturaz>
dAnjou, your way will do fine
asobrasil has joined #ruby
user398458 has joined #ruby
user398458 has quit [#ruby]
bglusman has joined #ruby
chalky has joined #ruby
drbawb has joined #ruby
casadei has joined #ruby
workmad3 has joined #ruby
<dAnjou>
arturaz: thanks
dAnjou has quit [#ruby]
egrouse- has joined #ruby
<arturaz>
zul__, try actually asking a question that can be answered
drknus has joined #ruby
workmad3 has joined #ruby
<stefanp>
What happens if I create an empty class and instantiate it and pass a hash to new?
waxjar has joined #ruby
Kar555 has joined #ruby
<stefanp>
Just saw that somewhere and wondered.
escobera has joined #ruby
smooth_penguin has joined #ruby
banjara has joined #ruby
<Kar555>
In irb, how can I list out all the available methods and options a library offers to me?
<Jck_true>
Missing ;? I thought Ruby decided thoose weren't needed :P
<Kar555>
Thank you banister
NotMyself has joined #ruby
<quacka>
runtime is givin u $end?
LBRapid has joined #ruby
<quacka>
that means ure if statements are bad
adambeynon has joined #ruby
<Jck_true>
They are dead simple :(
<Jck_true>
am i use "begin" properly?
<roderyk>
I'm trying to differentiate Request / Response classes that encapsulate logic for handling external requests (ie. what we get/send to clients) and internal requests (what we use to communicate to 3rd parties in order to handle client request). Any ideas for good synonyms for Request I could use? e.g. Query, Input, … ?
phantasm66 has joined #ruby
theRoUS has joined #ruby
yoklov has joined #ruby
wroathe has joined #ruby
<quacka>
yeah somethings up with your begin
ceej has joined #ruby
<Jck_true>
This is just retarded :S
<quacka>
i removed the begin and theres still errors!
<Jck_true>
same - Replaced it with "until" and - So its somewhere in between :S
<quacka>
paste ure new code
mikepack has joined #ruby
maletor has joined #ruby
burns180_ has joined #ruby
max_ has joined #ruby
Synthead has joined #ruby
carlyle has joined #ruby
<Jck_true>
quacka: Working now - Apprently primes++ aint valid ruby syntax
<lampe2>
hey iam new to ruby. i created a gem and in the lib/gemname folder i created a file called save.rb and init a class Save with a method now i wanne call that method in the file lib/gemname.rb and i got it required but this dont works: sl = new Save
<lampe2>
oh i got it
<lampe2>
it should be Save.new
<quacka>
u should get kicked for sayin taht
<lampe2>
???
Barakas has joined #ruby
philcrissman has joined #ruby
iocor has joined #ruby
pdtpatr1ck has joined #ruby
rippa has joined #ruby
nachtwandler has joined #ruby
stanman246 has quit ["Ik ga weg"]
robert_ has joined #ruby
robert_ has joined #ruby
tatsuya_o has joined #ruby
aibo_ has joined #ruby
looopy has joined #ruby
jgarvey has joined #ruby
<WhiteDice>
I'm trying to update ruby gems on a shared server in order to be able to install some redmine plugins but get the following:
<WhiteDice>
/var/lib/gems/1.8/gems/rubygems-update-1.8.17/bin/update_rubygems:34: warning: Insecure world writable dir /home/cfg/.gem/ruby/1.8/bin in PATH, mode 040777
<keymone>
hi guys, can't figure out why GC.start followed by GC.disable does not help me at all
LMolr has joined #ruby
<keymone>
trying to switch my app from fcgi dispatchers to unicorn workers and it's either using GC like crazy or if i disable GC and run it manually every few requests - it just kind of ignores GC run and eats memory until goes into swap
Targen has joined #ruby
<keymone>
fcgi dispatchers sit at stable memory level and it rarely goes up
<keymone>
using REE 2012.01 btw
minijupe has joined #ruby
rbennacer has joined #ruby
<rbennacer>
hey guys , what does gsub( /s$/, '') mean?
<rbennacer>
what does the '$' stand for?
<shevy>
robert_ hmm still thinking about how to control running ruby processes
Tearan has joined #ruby
Eiam has joined #ruby
<heftig>
rbennacer: end of line
<keymone>
rbennacer: $ is regexp token for "end of line" or "end of string" in multiline regexps
<robert_>
shevy: aha.
<davidcelis>
end of string
<davidcelis>
sorry, end of line
<davidcelis>
\z is end of string
tayy has joined #ruby
<rbennacer>
so .gsub( /s$/, '') means delete the end of the string?
<rbennacer>
like a trim?
ckrailo has joined #ruby
wallerdev has joined #ruby
Prezioso has joined #ruby
mdw has joined #ruby
<keymone>
delete 's' character if it's in the end of the string
roderyk has joined #ruby
<rbennacer>
ahh ok
<rbennacer>
thank you for your help
<keymone>
\s is token for whitespace so .gsub(/\s$/, '') *will* work kind of like trim
roderyk has quit [#ruby]
Drewch has joined #ruby
bragh has joined #ruby
kenperkins has joined #ruby
bragh has quit [#ruby]
priteshjain has joined #ruby
pdtpatr1ck has joined #ruby
<gyre007>
what is the best way to parse JSON, im a newbie here...so I would appreciate if you advised me the best json library etc. Also, how do you handle the case when a MASSIVE json document is returned to the calling program ? I mean it can create a massive memory spike on aprogram right ?
tatsuya_o has joined #ruby
drizztbsd has joined #ruby
DrForr has quit [#ruby]
rbennacer has quit ["Leaving"]
<drizztbsd>
hi, is there any way to use webrick httpproxyserver threaded and/or without locking IO?
JonnieCache has joined #ruby
cha1tanya has joined #ruby
jcromartie has joined #ruby
TheTFEF has joined #ruby
TheTFEF has joined #ruby
reitelles has quit [#ruby]
Squarism has joined #ruby
luckyruby has joined #ruby
lkba has joined #ruby
tewecske has joined #ruby
notjohn has joined #ruby
gnychis_ has joined #ruby
drake has joined #ruby
<keymone>
i fixed my problem by using GC.enable before GC.start btw. have to learn to rtfm doh
talin30 has joined #ruby
ed_hz_ has joined #ruby
iocor has joined #ruby
Squarism has joined #ruby
jgrevich has joined #ruby
flak has joined #ruby
PaciFisT has joined #ruby
looopy has joined #ruby
jlogsdon has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
emocakes has joined #ruby
eldariof has joined #ruby
Morkel has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
banisterfiend has joined #ruby
burns180 has joined #ruby
davidcelis has joined #ruby
theRoUS has joined #ruby
cdabba has joined #ruby
ascarter has joined #ruby
<cdabba>
whats the best way to sort a hash if each key is an id and each value is an array of ids and i want to sort the hash by the number of elements in each array
<cdabba>
davidcelis: so like .sort_by{|pair| pair.value.count}
<davidcelis>
No, you can do |k,v|
<davidcelis>
sort_by is smart
timonv has joined #ruby
<cdabba>
davidcelis: cool, thanks
sacarlson has joined #ruby
cloke has joined #ruby
xiaotian has joined #ruby
cloke has joined #ruby
j3r0m3 has joined #ruby
internet_user has joined #ruby
<mvangala>
[1,2,3,4,5].method_id
<mvangala>
I want to make method_id available for all classes that implement Enumerable
<mvangala>
any ideas?
<mvangala>
I was thinking of implementing self.each do end; in def method_id. But is not working. Am I missing something here?
Squarepy has joined #ruby
<davidcelis>
mvangala: if they're not behaving differently, define it on Object?
nemesit has joined #ruby
ryh has joined #ruby
<apeiros_>
mvangala: module Enumerable; def method_id; …your implementation…; end; end
<apeiros_>
done
mikewintermute has joined #ruby
<apeiros_>
davidcelis: no, you don't define stuff on Object that should not be available on *all* Objects.
<mvangala>
gonna try that; thanks apeiros!
<davidcelis>
oh whoops
iocor has joined #ruby
<davidcelis>
totally missed the "that implement Enumerable" part
<davidcelis>
sorry!
<apeiros_>
mvangala: this is called monkey patching. monkey patching core/stdlib classes should only be done carefully.
<apeiros_>
davidcelis: :-p
<apeiros_>
shit happens, I guess ;-)
<mvangala>
Roger that, apeiros
mikeg has joined #ruby
hobodave has joined #ruby
wmoxam_ has joined #ruby
LMolr has joined #ruby
Squarepy has joined #ruby
daniel_hinojosa has joined #ruby
centr0 has joined #ruby
centr0 has quit [#ruby]
centr0 has joined #ruby
<zaargy>
anyone generate a syntacally invalid erb?
<robacarp>
?
<zaargy>
i can't seem to
<zaargy>
checking with erb -x -T - $1 | ruby -c
<zaargy>
always gives syntax ok
hubub has joined #ruby
<gate>
zaargy <%= ' %>
tatsuya_o has joined #ruby
burns180_ has joined #ruby
<zaargy>
ah nice
<zaargy>
thanks
<zaargy>
just what i wanted
hubub has joined #ruby
cbuxton has joined #ruby
_adeponte has joined #ruby
ArielMT has joined #ruby
t0mmyvyo has joined #ruby
Gesh has joined #ruby
<robacarp>
You know. The reason I can't stand to write tests as I go is that the code works in the browser and not in the test.
MrGando has joined #ruby
danishkhan has joined #ruby
geef has joined #ruby
geef has quit [#ruby]
greenarrow has joined #ruby
adamkittelson has joined #ruby
<davidcelis>
if your code doesn't work in the test, there's two things that could be wrong
shadoi has joined #ruby
<davidcelis>
1.) your code is wrong
<davidcelis>
2.) your test is wrong
Pheen has joined #ruby
bluOxigen has joined #ruby
Seisatsu has joined #ruby
Seisatsu has joined #ruby
abstrusenick has joined #ruby
nobitanobi has joined #ruby
geekbri has joined #ruby
<nobitanobi>
Given a StringIO object. What's the difference between doing: myobject.read than myobject.string?
kuzushi has joined #ruby
QaDeS has joined #ruby
munx has joined #ruby
Spaceb0y has joined #ruby
tatsuya_o has joined #ruby
svnlto has joined #ruby
<svnlto>
any pointers on how to recursively copy a directory in rake?
minijupe has joined #ruby
Araxia has joined #ruby
danishkhan has joined #ruby
shlevy has joined #ruby
zommi has joined #ruby
<svnlto>
I got as far as moving all the files but what I really want is keep the folder structure
<shlevy>
If I pass an UnboundMethod to define_method, will it respect the scope at the point of define_method for closure variables?
chased has joined #ruby
Norrin has joined #ruby
nonotza has joined #ruby
<chased>
in a file a have a global function with name asdf. in that file, I also have a class having an instance method asdf and I want to call the global one from withing the instance method
<chased>
is that possible?
<chased>
(i know I could put the global one in a module and call Modulname::asdf)
jrist-afk has joined #ruby
<robacarp>
chased: I'm not sure, because I don't deal with global functions, but you might be able to just do ::asdf
<chased>
robacarp, i've tried that but doesn't work
<shevy>
chased can you upload your code to pastie
<shevy>
for instance, I never heard the name "global function" before
<shevy>
I guess it belongs to class Object if it has no other namespace
<Mon_Ouie>
You can only do ::Foo for constants
<Mon_Ouie>
For methods you do Kernel.asdf
<Mon_Ouie>
Which is the reason globally accessible methods should be defined as module_function in Kernel
<chased>
shevy, Mon_Ouie, robacarp tx =)
burns180 has joined #ruby
luckyruby has joined #ruby
io_syl has joined #ruby
notjohn has joined #ruby
hadees has joined #ruby
ph^ has joined #ruby
sdeobald__ has joined #ruby
havenn has joined #ruby
SegFaultAX|work has joined #ruby
sawgij has joined #ruby
oposomme has joined #ruby
sdwrage has joined #ruby
Sou|cutter has joined #ruby
lorandi has joined #ruby
flagg0204 has joined #ruby
interlocutor has joined #ruby
colinwd has joined #ruby
nfluxx has joined #ruby
apeiros_ has joined #ruby
ceej has joined #ruby
shadoi has joined #ruby
EvanR has joined #ruby
skitrees has joined #ruby
td123 has joined #ruby
startling has joined #ruby
<EvanR>
looking for a ruby reference plz
<EvanR>
comprehensive and dry
abstrakt has joined #ruby
<td123>
the ruby programming language
<EvanR>
pickaxe?
<td123>
no
<EvanR>
oh
<td123>
actually, I don't know how comprehensive it is or if there's a better one
<td123>
but I find it to be a good reference
<EvanR>
dang gigapedia and library.nu are gone
c0rn has joined #ruby
<pietr0>
EvanR: amazon.com is not
<EvanR>
i find amazon hard to navigate
<EvanR>
not paying money for that shit
<td123>
lol, then please keep it to yourself
ascarter has joined #ruby
<td123>
we don't want to hear about your pirating (mis)adventures
<EvanR>
please keep that to yourself
havenn has joined #ruby
Drake_mac has joined #ruby
Sou|cutter has joined #ruby
<apeiros_>
EvanR: the one from matz and flannagan is quite comprehensive
eldariof has joined #ruby
Squarism has joined #ruby
casadei has quit [#ruby]
hadees has joined #ruby
<EvanR>
thats the same thing right, the ruby programming language
<apeiros_>
ah, right, td123 mentioned it already
moshef has joined #ruby
robbyoconnor has joined #ruby
maletor has joined #ruby
Seisatsu has joined #ruby
moted has joined #ruby
burgestrand has joined #ruby
<cloke>
I'm trying to send mail to a remote smtp server who's authentication method is "password", but this doesn't seem to be one of the options in action mailer. Any ideas what the correct setting would be?
TheTFEF has joined #ruby
<cloke>
oops, sorry just realized I am in the ruby channel
<apeiros_>
actionmailer is part of rails, I suggest asking in #rubyonrails
<EvanR>
if this is hell, you can decomission heaven and save on operating expenses
<dr_bob>
Kyle__: I don't think Ruby does it on any platform
KL-7 has joined #ruby
<deryldoucette>
decommission heaven. hahahah love it!
robbyoconnor has joined #ruby
HectorMalot has joined #ruby
dbgster_ has joined #ruby
<shevy>
dr_bob: that's what she said
Azure has joined #ruby
<dr_bob>
who?
<Kyle__>
dr_bob: It does in linux and AIX I know.
burns180 has joined #ruby
<HectorMalot>
hey all
<dr_bob>
Not on my linux
<Kyle__>
Ahh. yea, that's what it was. Switched to USER["HOME"], and it's happy.
<HectorMalot>
any chance somebody could help me out with a question regarding the GC?
<Kyle__>
dr_bob: Really? I've had it work on CentOS/RHEL Ubuntu and Debian. Humm.
<Kyle__>
dr_bob: Which linux?
thedoor has joined #ruby
<thedoor>
Hi Guysa
albemuth has joined #ruby
<thedoor>
I have some objects, and all of them have the "Date" attribute
<thedoor>
how can i get the older one?
<shevy>
what
snip_it has joined #ruby
<thedoor>
Lol
badabim_ has joined #ruby
<shevy>
well perhaps others understand that
<thedoor>
For example, i have persons objects, and they have a bithday date, i need to get the older.
<shevy>
I seem to lack context to understand what object it is, if you wrote the class yourself, what you mean with "Date" attribute (an instance var?), and what you mean with older "Date" attributes
<thedoor>
Im using rails =/
<deryldoucette>
anyone here have a recommendation for an ebook I can paypal that covers specifically the testing facilities in ruby 1.9?
<HectorMalot>
BAM!
<HectorMalot>
:)
<shevy>
well they are on #rubyonrails
<thedoor>
Ok, tks
<shevy>
we here know more about ruby though!
<deryldoucette>
i use rspec and cucumber now, looking for a book covering the testing stuff that ruby comes with
<deryldoucette>
(minitest isn't it?)
<shevy>
the only real test is to ask people to try to break things!!
sungji has joined #ruby
<deryldoucette>
lol
<dr_bob>
Kyle__: 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:50:54 UTC 2012 i686 i686 i386 GNU/Linux
<gate>
Rule #1 of testing: nothing is foolproof for a sufficiently talented fool
<Kyle__>
dr_bob: I'll admit I wrote this code awhile ago, but that's surprising. I'm gonna go test with 1.8 vs 1.9 vs 1.9.1 when I get home now.
cyri_ has joined #ruby
<dr_bob>
I have 1.9.3
<dr_bob>
built from sourced
<dr_bob>
sources
<dr_bob>
CU
mohawkjohn has joined #ruby
<mohawkjohn>
What should the initialize function in a C extension return? The class (the last argument) or the instance?
faint545 has joined #ruby
<EvanR>
im converting shell scripts to ruby because shell is not sufficiently hip
<faint545>
im writing a script which needs to display html tags.. is there an easy way to escape html in ruby?
<shevy>
EvanR shell scripts are very ugly and limited
libertyp1ime has joined #ruby
<deryldoucette>
limited... how?
<shevy>
EvanR, give me the shortest solution to split a string "/foo/bar/bla-1.0.0" into an array delimiated by "/"
<Kyle__>
But they are the right tool for some, even many, jobs. Some jobs need a hammer, some need a swiss-army-knife.
<EvanR>
it can do the job is less space and less headache, for some jobs
<shevy>
deryldoucette, in everything. give me a bash only solution please ;D
<EvanR>
in less*
* Kyle__
nods
<deryldoucette>
the point of shell scripting is to help glue together programs for what isn't in the language itself.
<EvanR>
if the code fits on a page, thats way better
<deryldoucette>
so its not wrong to pull in sed
<shevy>
deryldoucette but then I can use ruby just as well
<deryldoucette>
true, but that doesn't make shellscripting 'wrong'
Morkel has quit [#ruby]
<shevy>
of course not
<shevy>
if ruby is unavailable :)))
<deryldoucette>
lol
<deryldoucette>
touche :)
<rippa>
shellscripts are for working everywhere
<rippa>
were there is shell
<shevy>
in ruby I can do .split "/"
<EvanR>
if youre mostly running programs and testing results and the filesystem i wouldnt want to use ruby
libertyp2ime has joined #ruby
<shevy>
well there is only one valid concern I can agree with in principle, which is speed. I am sure grep, sed, awk are very fast, most likely faster than if you'd use pure ruby solutions instead
<EvanR>
im reading this matz and flagan book to see how error handling works when you use ruby as a shell script
<EvanR>
if you have to do more than bash -e its going to suck
<shevy>
sed is actually elegant compared to most of them
<deryldoucette>
straight shell code
<shevy>
sed -e 's/;/\n/g'
<shevy>
deryldoucette who is deryl
wmoxam has joined #ruby
<deryldoucette>
me
<shevy>
ah ok
jergason has joined #ruby
<EvanR>
writing computations and algorithms in shell ehhhh yeah no. writing shell script in not the shell ehhhh
<deryldoucette>
that shell tends to go up and down, and this is the house which also goes up and down due to the local provider being as stable as sand under assault from water
Keva161 has joined #ruby
<greenarrow>
<shevy>
hmm
<shevy>
I like sand, the ocean, the little crustacaeans that are running around
mengu has joined #ruby
<deryldoucette>
yep me too.
<deryldoucette>
just was trying to evoke a mental picture :)
i8igmac has joined #ruby
<EvanR>
i like stuff to work
<EvanR>
probably more than most people
<deryldoucette>
hehe. i'd say we might be even on that score
<deryldoucette>
but thats a free shell so i can't really complain
rudyl313 has joined #ruby
apucacao has joined #ruby
QKO_ has joined #ruby
<shevy>
yeah, that ocean picture makes me happy
<shevy>
looking at shell scripts makes me not so happy
<shevy>
ruby code, depends. if it is elegant it makes me happy even if it came from other people
<rudyl313>
how can I get "bundle install" to not install ri and rdoc?
<deryldoucette>
hehe my code is FAR from elegant. right now, i'm more worried about working. I can always review later and redo as i learn more and more
<shevy>
deryldoucette well for big projects, many files ... but
<shevy>
small classes? your small classes are clean, aren't they? :)
<deryldoucette>
shevy: *I* think so
<deryldoucette>
but i also am not a big believer in terse
badabim has joined #ruby
<deryldoucette>
a = B.new is < new_car = Vehicle.new
machine1 has joined #ruby
<HectorMalot>
rudyl313 add gem: --no-ri --no-rdoc to your .gemrc
<shevy>
ah I see
<shevy>
I love terseness a lot :)
<shevy>
I am even trying to find ways to tersify documentation
<shevy>
(but not on tutorials. I am verbose with tutorials and all my larger projects get a detailed tutorial.)
<rudyl313>
HectorMalot: where does the gemrc file go?
<HectorMalot>
home dir
<shevy>
deryldoucette yeah, class names are long
<deryldoucette>
i was making mention of that today to Trevor and Brian Marick today
<shevy>
not sure about new_car though
<deryldoucette>
on twitter
<shevy>
if there are lots of different classes, yeah
<shevy>
but for small things, I like to do:
<shevy>
_ = Vehicle.new
<deryldoucette>
I should have just done car not new_car
<shevy>
hehe
<deryldoucette>
but was trying to put up a quickie
<shevy>
a bit better yeah :D
Russell^^ has joined #ruby
<deryldoucette>
then again I also believe in multi-line comments in code whereever i think someone (including myself) might have issues.
<deryldoucette>
i get yelled at by a few for that but i don't care
<greenarrow>
* apeiros_
thinks having comments within the code (i.e., not the API-doc-comments) are a (minor) code-smell
<apeiros_>
they become a bigger codesmell if they explain *what* is being done
bwlang_ has joined #ruby
<deryldoucette>
apeiros_: i do that occasionally (usually for myself)
<shevy>
I do that all the time!
KL7 has joined #ruby
fbernier has joined #ruby
<shevy>
but mostly because I once wanted to document every method
<shevy>
and they all got a fancy header, and multiline description
<deryldoucette>
like in my rvm-test project. I left notes all over the place. mainly because I want something to remind me wtf i was doing hehe
<deryldoucette>
same with the fs_specs in a couple places.
<shevy>
yeah that I can understand
<shevy>
but there is also really easy and straightforward code
<apeiros_>
shevy: I'm not talking about API doc comments (specifically excluded that) ;-)
<shevy>
like:
<shevy>
def exit
<deryldoucette>
my short term memory is a bit.. fucked. so notes like that REALLY help ME out a lot
<shevy>
(just an example)
<shevy>
And I always wondered whether I should write "This will exit the program." there
<deryldoucette>
shevy: lol
<deryldoucette>
i'm not *that* bad ;)
<deryldoucette>
close, but not there yet
<shevy>
I kinda did that
<deryldoucette>
i also think of it from a newbie's pov. i mean he/she is having a hard enough time with the language. the better the explanation of why, what tended to help me out big time when i *first* got started, and they still do quite a bit.
<deryldoucette>
so i kind of also do it for the new guy too
<shevy>
well explaining why is fine
<shevy>
but just take the example of many many small tiny methods that do just one thing
<shevy>
like, to exit
<shevy>
it's kinda odd to document these
<shevy>
but if I dont, then only some methods get documented... and some others do not get documented at all
<deryldoucette>
yeah, self apparent i tend not to. but my longer methods/actions/functions I do
* apeiros_
thinks newbies should not be the standard for comments
<apeiros_>
I think a reasonable expertise can be expected from a fellow coder. yes, it means it'll be harder for newbies, no, it won't make it impossible.
<deryldoucette>
screw it i don't care what the com,unity calls it. methods and functions work. interchangable and most people understand what you mean. so.. methods or functions (though i prefer method) it shall be
Paul321abc has joined #ruby
<deryldoucette>
apeiros_: yeah i can see your point. dont *totally* agree however i see where you're coming from
<shevy>
well the world won't come to an end whether they are called method or functions
<shevy>
in nimrod they are called procedures, kewyword "proc foo" :>
timonv has joined #ruby
<deryldoucette>
for rails I call them actions or methods because usually the method is defined for/as an action. so there i can see
<deryldoucette>
but for generalistics, i prefer the term method
<apeiros_>
deryldoucette: srsly? I'd say less than 1 out of 20 methods in my rails projects are actions…
<apeiros_>
probably even far less
<shevy>
waaaah!
<deryldoucette>
i brought it up only because i was expecting to get told off for using 'method' or 'function'
<shevy>
you have been assimilated into raaaaails!
<deryldoucette>
lol
<apeiros_>
shevy: it earns me money. I still don't like it.
<apeiros_>
that recent github break was just water on my mills…
<shevy>
yeah I am not going to rant much
<shevy>
one day I may be in that boat too
<shevy>
but still I am shivering slightly!
<apeiros_>
(srsly, input sanitation in the models is soooo obviously wrong…)
machine1 has joined #ruby
<deryldoucette>
i learned rails, but i'm finding that i'm moving away from it to either straight up core ruby or using something like ramaze which i *really* like.
minijupe has joined #ruby
<deryldoucette>
helps too that I know the creator. so i can always dog him for an aswer of how to do this or that cleaner than i could in rails
<apeiros_>
shevy: anyway, even though I very much dislike rails, it still allows me to use ruby to earn money. which is great.
<deryldoucette>
s/aswer/answer/
<deryldoucette>
apeiros_: good point
<deryldoucette>
money is money. do what ya gotta do
<apeiros_>
rails over php any time
<deryldoucette>
fuck yeah
<shevy>
apeiros_ yeah I can see that
<deryldoucette>
sorry, mouth deryl mouth
<apeiros_>
*rails over any php framework, any time (fixed)
<shevy>
Agreed too :)
kirun has joined #ruby
<deryldoucette>
the only php i use at all is a single wordpress blog. i run a terrorism/counter-terrorism blog. uses wordpress
<Drewch>
How come at the end of my ruby program it prints %
<deryldoucette>
hosted elsewhere, only place i use it of my own volition
<Drewch>
and the only way for it not to happen is if I end my program with a new line
<shevy>
well, *using* and *maintaining* wordpress is not so bad
<apeiros_>
Drewch: you're doing something very odd?
s_dana has joined #ruby
<shevy>
I admined for a game project for a while, it was quite convenient (well, minor some stupid warts, like spam bot attacks annoying me)
<deryldoucette>
shevy: oh yeah i definitely wouldn't want to *code* in php for it
<rippa>
*Terrorists win*
<apeiros_>
deryldoucette: TSA vs. the people?
<Paul321abc>
hi! iam making small test:unit clone and have problem..
<deryldoucette>
apeiros_: hehe touche! :)
<Drewch>
ok apeiros_ thanks, just checking if there's a specific way to end ur code in ruby like exit() or something
baroquebobcat has joined #ruby
<axl_>
Hey guys, I am using the ruby library to manipulate zip files. any idea why require 'zip/zip' would be erring out on me?
<apeiros_>
Drewch: no, having "%" printed at the end of your script is not normal ruby behavior, if that helps.
<geekbri>
does ruby 1.8.7 support multipleentries for one attr_reader or does each need to have its own line?
<Mon_Ouie>
You can pass multiple arguments just fine
<geekbri>
ty
<geekbri>
oh its just that in 1.9.x you can use attr instead of attr_reader right?
<geekbri>
i know _something_ changed
<Mon_Ouie>
I can't think of any difference. I never actually used attr, though (but it did exist back in 1.8)
colinwd has joined #ruby
<geekbri>
i think in 1.8.7 you can only feed attr one argument but in 1.9.2 you can give it multiple
Paul321abc has quit [#ruby]
baroquebobcat has joined #ruby
Squee-D has joined #ruby
jamw has joined #ruby
centr0 has joined #ruby
havenn has joined #ruby
mikeric has joined #ruby
thecreators has joined #ruby
Drake_mac has joined #ruby
Quirrell has joined #ruby
Quirrell has joined #ruby
imsplitbit has joined #ruby
<greenarrow>
shruggar has joined #ruby
thedoor has joined #ruby
DrShoggoth has joined #ruby
nobitanobi has joined #ruby
hooper has joined #ruby
Redjack1964 has joined #ruby
bwlang_ has joined #ruby
A124 has quit [#ruby]
hadees_ has joined #ruby
<nobitanobi>
Whats the difference when using Spreadsheet between doing this: file_io = StringIO.new; book.write file_io; file_io.string and file_io = StringIO.new; book.write file_io; file_io.read ?assuming book is a spreadsheet?
<locojay_>
hi i m pretty new to ruby ... I m installing sup wich requires ncursesw. unfortunattly ncursesw fails so gem tails me whre its downloaded . looking at the code i maanged to fix ruby extconf.rb;make;make install. it installs but no as a gem and doing gem install ncursesw again fails as it deletes the fail folder. any idea?
shruggar has joined #ruby
<td123>
locojay_: any errors?
<locojay_>
same as before. just need to edit a file in the gem extconf.rb
nuba has joined #ruby
jbw_ has joined #ruby
robbyoconnor has joined #ruby
Knodi has joined #ruby
Norrin has joined #ruby
danishkhan has joined #ruby
robbyoconnor has joined #ruby
Targen has joined #ruby
jesly has joined #ruby
Squarepy has joined #ruby
Richmond has joined #ruby
machine1 has joined #ruby
dzhulk has joined #ruby
Knodi has quit [#ruby]
Squarepy has joined #ruby
gary_r has joined #ruby
demian`_ has joined #ruby
flazz has joined #ruby
<flazz>
when i open irb in a non-tty it echos the input, is there a way to turn that off?
danishkhan has joined #ruby
<lectrick>
in irb:> "\+" #=> "+", that's OK. Then, "\\+" #=> "\\+" SAY WHAAA? How have I not noticed this until now lol
<lectrick>
I would expect "\\+" to evaluate to "\+"
<wallerdev>
it does
<wallerdev>
it's escaping it for you
<wallerdev>
try puts "\\+"
jergason has joined #ruby
burns180 has joined #ruby
artOfWar has joined #ruby
tomsthumb_ has joined #ruby
jeffsmykil has joined #ruby
<lectrick>
interesting.
gyre007 has joined #ruby
Boohbah has joined #ruby
<jeffsmykil>
how would I make it so the folllowing line doesn't have a break after #{randomEquip} ?
<gyre007>
print "HASH" if data.is_a?(Hash) prints "HASH" proving that the returned data IS a hash...yet when I call parse_structure on it it falls straight the the "else" clause in the case statement...am I missing something ??
bwlang_ has joined #ruby
fr0gprince_ has joined #ruby
munx has quit [#ruby]
munx has joined #ruby
munx has quit [#ruby]
munx has joined #ruby
senjin has joined #ruby
sirdeiu_ has joined #ruby
<shadoi>
gyre007: just use: when Hash
<shadoi>
when Array
<gyre007>
but even so...
twqla has joined #ruby
<gyre007>
it should work as it is...
<shadoi>
no
<gyre007>
shouldnt it ?
<gyre007>
no ?
<shadoi>
it uses ===
<shadoi>
Comparable
<shadoi>
read up on ti
<shadoi>
it*
<gyre007>
shadoi, AHHH...I knew I missed something :)
<gyre007>
shadoi, yeah...cheers..I know that case uses === ...im a beginner so it slipped my mind...got carried away :) made quite a few bugs in that code..
KL-7 has joined #ruby
BrokenCog has joined #ruby
<gyre007>
shadoi, another q :)...when I pass hash into it it doesn't seem to be getting its value...
<gyre007>
might be a problem of passing hash to it or something with retrieving the value per key...
<shadoi>
I noticed you're using symbols for the keys, are the keys actually symbols in the data?
<gyre007>
nope, just strings
kpkpkp has joined #ruby
<gyre007>
but I though the value of a symbol is string so parse_structure(var[:"#{key}"]) should work
<davidcelis>
baniseterfiend`: dude every time i come in here your name is different by 2-3 characters
<Mon_Ouie>
Don't use a case then?
<davidcelis>
bannisterfiend``, banisterfiend, now baniseterfiend`
<baniseterfiend`>
jlebrech: send(k)
appineer has joined #ruby
<davidcelis>
send(k) if v
<Mon_Ouie>
And you can e.g. use inject to call it on the result of the previous call if the option is set, or not call anything if the option isn't set
<davidcelis>
and as long as those methods return self, you can chain them
<Mon_Ouie>
Oh, actually no need for an if.
burns180 has joined #ruby
flazz has quit [#ruby]
stephenjudkins has joined #ruby
<Mon_Ouie>
inject { |obj, (k,v)| obj.send(k) }
machine1 has joined #ruby
<Mon_Ouie>
And your options would make more sense in a Set than in a Hash
chimkan has joined #ruby
jellosea has joined #ruby
jergason has joined #ruby
rushed has joined #ruby
<jellosea>
say i have array of maps, like [{foo: blah, bar: blah2}, {foo:woof, bar:meow}], whats the easiest way to get just a list with all the foo values? i.e. [blah, woof]
<jlebrech>
Mon_Ouie the option names might be totally different from the method i want to chain
Danielpk has joined #ruby
<Mon_Ouie>
Also, doesn't your where method support hashes with more than one elements?
<Mon_Ouie>
Because then you could just do where(options).limit 10
<Mon_Ouie>
jellosea: map { |hash| hash[:foo] }
minijupe has joined #ruby
SullX has joined #ruby
havenn has joined #ruby
withnale has joined #ruby
<jlebrech>
Mon_Ouie you gave me a brainwave :D :default_opts = {...}; :default_opts.merge!(:options) ?
<BrianE>
jlebrech: I do that all the time. Clean, readable, simple. Go for it :)
<jlebrech>
i can do merge all the way down my case and then do when(:default_opts)
<davidcelis>
jellosea: those are called hashes in ruby, not maps
<jlebrech>
boooya
withnale has quit ["Leaving"]
<BrianE>
jellosea: If that array is called 'things', then: things.collect{ |thing| thing.foo }
<BrianE>
Typo.
<BrianE>
jellosea: If that array is called 'things', then: things.collect{ |thing| thing[:foo] }
<jellosea>
where do i assing the array that i want to put the stuff into
<BrianE>
If it were a method you could even: things.collect(&:foo)
<davidcelis>
assign it to a variable
<BrianE>
:)
<davidcelis>
don't .collect
<davidcelis>
.map
<jellosea>
whats the difference i was just reading up that
virunga has joined #ruby
<davidcelis>
jellosea: one is an alias of the other, but .map is preferred for shorter syntax
<jlebrech>
i was frickin' reinventing merge! i'm such an ass
<BrianE>
davidcelis: "Preferred" is subjective. For me, 'collect' is more readable and makes more sense than 'map' when you're collecting just one property/thing
<BrianE>
This is Ruby, we don't care about extra key presses. Much :)
<lectrick>
How do I force a value to be an array if it isn't, in a slick one liner? I've seen this before
<lectrick>
like, wrap it in an array unless it is an array
<BrianE>
lectrick: Array.wrap(thing)
<lectrick>
nice
<BrianE>
From ActiveSupport, IIRC
<SullX>
I am new to defining my own methods but here is the gist: i have a bunch of code that runs and calculates a value from a bunch of data found in a db; the very last line of code is setting a variable = to the calculated value. Now I want to make this code a method so that every time it runs, it spits out the calculated value, and so that it can be called from within a large program. This is what I tried def start; ###all the code### @varia
<davidcelis>
BrianE: but you're mapping values into something else, not really collecting them.
<SullX>
how can I access this calculated value in the bigger program?
<lectrick>
BrianE: Oh, is there a way that doesn't depend on activesupport? This is for a lib
<davidcelis>
map is just more idiomatic than collect for ruby
you_can_call_me_ has quit [#ruby]
<lectrick>
BrianE: It's Array(value) haha
<BrianE>
lectrick: Neat :)
emmanuelux has joined #ruby
<SullX>
wow
<SullX>
return @variable
<SullX>
:P. told you I was new
<BrianE>
davidcelis: IMO it reads better for symbol-to-procs. EG, things.collect(&:foo) is like "grab all the 'foo's out of things", whereas "map" reads as "for each of the things, throw this onto a list and give me that back"
<BrianE>
SullX: You shouldn't need the "return"
TheTFEF_ has joined #ruby
<davidcelis>
things.map(&:foo) # => maps each thing into thing.foo
<BrianE>
Just @variable at the end :O
<davidcelis>
still reads as map to me
<davidcelis>
you're mapping
<SullX>
BrianE: ty
<BrianE>
davidcelis: Yeah. Just personal preference I guess. I think of map as "do this for each and give me the result" where collect is "get this property from all" without any thinking
<BrianE>
Don't know if anyone else does, it just reads much easier to me for what's a couple extra key presses
tatsuya_o has joined #ruby
KL-7 has joined #ruby
<davidcelis>
Question for y'all; is it ever really acceptable to just `raise "some error message"`
<davidcelis>
Or should you always try to raise an actual exception subclass?
<baniseterfiend`>
raise "some error message' is fine if u want a RuntimeError
<BrianE>
^
<davidcelis>
Yeah but I see people do this all the time for what isn't really a RuntimeError
<davidcelis>
they'll raise if an object in the app just isn't in the right state to accept the logic being called
<BrianE>
It's fine if you never want to catch it
<baniseterfiend`>
well everything is a runtime error ;)
<baniseterfiend`>
its just a generic catch all error really
logic has joined #ruby
KL-7 has joined #ruby
TheTFEF has joined #ruby
<jlebrech>
here's the bad boy http://pastie.org/3537452 i bet it can be even shorter with collect i think :D
<jlebrech>
it 9 mins to midnight
<baniseterfiend`>
Mon_Ouie: goede morgen
tatsuya_o has joined #ruby
<SullX>
BrianE: one other question? now that I have this value for use in the main program, assigned to a variable, I now want to call another method on it that will modify the contents of the value. How can I define a function to edit this value?
jergason has joined #ruby
<SullX>
inotherwords, how can I "pull" this value into the functions file for manipulation