Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
<andrewvos> That's pretty complex :)
<andrewvos> But it should work.
ilyam_ joined #ruby-lang
srbaker joined #ruby-lang
<andrewvos> Hmmm, so eval passing in some object __binding__ seems to be what I'm after.
replore joined #ruby-lang
setmeaway joined #ruby-lang
sulo joined #ruby-lang
tomzx joined #ruby-lang
havenn joined #ruby-lang
macmartine_ joined #ruby-lang
<perryh-> hey, I'm trying to convert the string "008" into an integer by type casting it, but I am getting an error "invalid value for Integer(): "008""
<erikh> that's because 008 isn't an integer
<perryh-> but it is working for "001", "002", etc
<erikh> oh,w ow
<shevy> hmm
<erikh> that's principle of most surprise :)
<erikh> those are octal notation
<erikh> that's why 008 doesn't work
<erikh> trim the zeroes. thank me later.
<perryh-> cool, thank you
<injekt> if you want an integer from that string you want to_i
<injekt> Integer('010') #=> 8
<injekt> '010'.to_i #=> 10 (probably what you want)
<perryh-> that works
<perryh-> pokenum = Integer(pokenum.to_i)
<injekt> yeah
<injekt> or just alter the base
<injekt> Integer('010', 10) #=> 10
<lianj> to_i(base)
<perryh-> nice
neoesque joined #ruby-lang
<zedUNDginger> erikh: what do u think of this? https://github.com/d11wtq/whittle
<zenspider> YUCK
<zenspider> headius: oi
<petercooper> reminds me of parslet
<zenspider> parselet is peg, tho, right?
<petercooper> Oh, yeah
<headius> hmm?
<zenspider> headius: https://github.com/seattlerb/minitest/issues/57 latest comment
dejongge1 joined #ruby-lang
<headius> ok...saw your paste the other day but lost it in the queue
<headius> will have a look at this
<zenspider> kk
enebo joined #ruby-lang
<jaimef> https://gist.github.com/1402857 is there a simpler way of pulling out "halt"?
<manveru> >> "a\nb\nc\nd\ne halt"[/^e (.*)/, 1]
<manveru> => "halt"
<jaimef> nice, did not know you could apply regexp directly like that.
<injekt> >> "a\nb\nc\nd\ne halt"[/^e (?<word>.*)/, :word]
<injekt> => "halt"
<injekt> I'll see myself out
<manveru> :)
queequeg1 joined #ruby-lang
looopy joined #ruby-lang
<manveru> now if i just could find a way to abuse inject for that
<injekt> I read that as 'abuse injekt for that'
<injekt> heh
jmontross joined #ruby-lang
<diegoviola> is there a better way to get the year/month than using Time.now.strftime('%B') and %Y?
<drbrain> t = Time.now; p [t.year, t.month]
<drbrain> ?
<diegoviola> thanks
andrewhl joined #ruby-lang
<diegoviola> i need month with names
<diegoviola> like "November"
<drbrain> t = Time.now; p [t.year, Date::MONTHNAMES[t.month]]
<petercooper> What do you mean by 'better'?
<zenspider> diegoviola: if you have an answer that works... why do you want "better"?
<zenspider> better than what? than working? it works... move on
<zenspider> petercooper: jinx? :P
<petercooper> I was going to call it because one of us might have to stay silent until the other one says it again.
<petercooper> s/was/wasn't
<diegoviola> sorry i was curious
* petercooper forgets all the playground rules
<petercooper> I believe activesupport has some stuff for doing dates with i18n and the like
<petercooper> But I find i18n eye-clawingly dull so I'm not rich on the details.
[MEX]_HA joined #ruby-lang
perryh_ joined #ruby-lang
perryh_ joined #ruby-lang
spuk joined #ruby-lang
flip_digits joined #ruby-lang
ilyam joined #ruby-lang
looopy joined #ruby-lang
<shevy> hehe
<shevy> "I find i18n eye-clawingly dull" I should start to collect best-quotes from #ruby-lang
<shevy> diegoviola well a bit differnet could be Date::MONTHNAMES[Date.today.month] # => "November"
<shevy> *different
<diegoviola> ty
steph021 joined #ruby-lang
steph021 joined #ruby-lang
<lianj> Time.now.strftime("%B")
<shevy> we had that!
<shevy> we need one hundred more ways
<shevy> hmm
<lianj> oh, i didn't scroll up :)
ilyam joined #ruby-lang
dhruvasagar joined #ruby-lang
savage- joined #ruby-lang
dreinull joined #ruby-lang
srbartlett joined #ruby-lang
curtism joined #ruby-lang
Banistergalaxy joined #ruby-lang
<Banistergalaxy> Haha is it wrong for a 14 year old to read lots and lots of kafka?
<shevy> depends
<shevy> I find Kafka boring
<shevy> so I find it odd that anyone reads kafka!
<jmontross> kafka is kinda boring.
<jmontross> it's more wrong for a 30 year old to have read kafka since he was 14 :)
<Asher> kafka just hasn't been translated into english yet
<Asher> kafka in german is amazing
towski joined #ruby-lang
<Asher> the muirs ruined kafka for english audiences
<Asher> turned him into a schizo-depressive figure
<Banistergalaxy> Kafka is only boring if you don't understand it shevy
<Banistergalaxy> Which is your fave story asher
<jmontross> lost in translation.
<jmontross> makes sense.
<Asher> before the law
<Banistergalaxy> Haha we even read that in law school
<Banistergalaxy> Are you fluent in german asher?
<Asher> yea
<Banistergalaxy> Our was that google translate
<Asher> hahah i hope it reads better than google translation
nuclearsandwich joined #ruby-lang
thone joined #ruby-lang
porcelina joined #ruby-lang
srbartlett joined #ruby-lang
srbaker joined #ruby-lang
dreinull joined #ruby-lang
ilyam joined #ruby-lang
twittard joined #ruby-lang
robbyoconnor joined #ruby-lang
srbartlett joined #ruby-lang
zedUNDginger joined #ruby-lang
ecin joined #ruby-lang
looopy joined #ruby-lang
<Xzyx987X> although this may seem like an insane idea (as most of my ideas do), I was wondering if the ruby gods of metaprogramming have provided us with a way to take a reference to a class, and use it to get the complete definition of that class?
<Asher> what do you want to know
<Asher> you want source code? or you want to know what methods it provides and such
<Xzyx987X> source code
<injekt> no
<Asher> ask banistergalaxy about that he's hooked up pry to look up source… i think ruby just provides the location tho built in
<lianj> 1.9 has method(:foo).source_location
<injekt> 'source code'
<Xzyx987X> what if the class was defined dynamically, as in an irb type environment?
<injekt> Xzyx987X: no, you need to parse the source code
<zedUNDginger> Xzyx987X: if you want method source, that's possible, but it's much harder and may not even make sense in the case of classes
<zedUNDginger> Xzyx987X: the reason it may not make sense for classes is they can be reopened and monkeypatched in any number of files, so there's not just a single definition
<Xzyx987X> yea, that's what I thought. maybe I need to figure out a way to detect a class definition on the fly and just save it when it happens
<zedUNDginger> Xzyx987X: but it definitely makes sense for methods, and you can get method source
<injekt> save what?
gnufied joined #ruby-lang
<porcelina> what is even the underlying data type for a method?
<porcelina> is it bytecode?
dave_miles_cf joined #ruby-lang
<Xzyx987X> by the way, this is for little project I'm doing to let people write their own adventure games in ruby
<porcelina> lol doesn't ruby let people write their own adventure games in ruby? :v
x0F_ joined #ruby-lang
<zedUNDginger> x0F_: hello
Wardrop_ joined #ruby-lang
<Xzyx987X> eh, my idea kind of let's people combine their adventures with those written by other people
<porcelina> oh, that's pretty cool
<zedUNDginger> has anyone found a way to make testing fun
<porcelina> name all your mocks funny things?
<Xzyx987X> it basically creates a combination between an adventure game an wikipedia
<porcelina> ;o
<porcelina> actually that sounds really cool
<Xzyx987X> yea, so nobody steal my idea til it's done ;P
<lianj> zedUNDginger: text-to-speech the output?
<injekt> lol
<Wardrop_> Can someone remind me how I can partition a flat array (e.g. ['dog', 'cat', 'horse', 'mouse', 'rat', 'zebra']) into pairs such as [['dog', 'cat'], ['horse', 'mouse'], ['rat', 'zebra']]]
<injekt> that would be annoying
<zedUNDginger> Wardrop_: each_slice(2).to_a should do it
<porcelina> Hash[array].to_a might do it...
<injekt> both work, you should use each_slice
<porcelina> yeah mine's stupid lol don't use it
<zedUNDginger> porcelina: lulzy
<porcelina> i think i've seen people use it tho. o_o
<zedUNDginger> porcelina: that's cute
<zedUNDginger> porcelina: did you just come up with that now
<injekt> it's not stupid, it just does too much work
<injekt> pointless work*
<injekt> so why did I only learn about _ in irb this week?
<injekt> that's retarded
<zedUNDginger> man ruby is going to so badass when we get that 'lazy' method on Enumerable
<porcelina> what's _ in irb?
<injekt> porcelina: try it?
<lianj> injekt: hihi
<zedUNDginger> to be*
<injekt> zedUNDginger: 'when'?
<zedUNDginger> injekt: probably 2.0
<porcelina> oh, it's like perl's $_?
<injekt> porcelina: no
<injekt> zedUNDginger: eh, with all existing methods?
<zedUNDginger> injekt: not quite sure what u mean but ill look up and see if i can find when matz talked about
srbartlett joined #ruby-lang
<injekt> zedUNDginger: will we get lazy ranges? ;)
edwardsharp joined #ruby-lang
igotnolegs joined #ruby-lang
<zedUNDginger> injekt: all Enumerable methods will have lazy variants, so you'll get shit like: (1..Infinity).lazy.select(:even?).map { |v| v ** 2 }.take(20)
<zedUNDginger> &:even?
<zedUNDginger> as discussed there ^
<injekt> hm
chessguy joined #ruby-lang
<injekt> If your proposal is accepted, I want Scala-like force
<injekt> oh yes!
jstemmer joined #ruby-lang
<Wardrop_> zedUNDginger: Cheers mate
hahuang65 joined #ruby-lang
Ruthenium joined #ruby-lang
hagabaka joined #ruby-lang
headius joined #ruby-lang
<shevy> hmm def foobar() ... inside the method foobar, is there an easy way to find out the name of the method?
<shevy> with caller() it's possible but that feels a bit inelegant to split the string
<lianj> shevy: __method__
<shevy> ah yes, thanks lianj
srbartlett joined #ruby-lang
<zedUNDginger> lianj: I LIKE __method__ it's a magic portal
<slyphon> anyone ever seen OSX throttle connections somewhat mysteriously?
<slyphon> oh gawd
<slyphon> i'm an idiot
* slyphon gives his server > 40MB of ram
<zedUNDginger> slyphon: your name is appropriate for a witch in slytherin
<slyphon> heh
<zedUNDginger> i have a pterodactyl nickname
<slyphon> i assure you any resemblance is merely coincidental
<jmontross> what is _method and why magic?
<jmontross> is it like .send(:method)
<jmontross> ?
<zedUNDginger> jmontross: why would you think it'd be like that
<jmontross> dunno. that one is kinda magical too
<jmontross> so im wondering what this _message is
<jmontross> errrr _method
<jmontross> _method_ rather
<jmontross> what is that
<lianj> __method__
<lianj> try it
<slyphon> jesus, the GC is sucking my will to live
<jmontross> __method__
<jmontross> => :irb_binding
<jmontross> GC? general consumer?
<porcelina> try it in a method. :P
<slyphon> jmontross: garbage collector
<lianj> def a; send __method__; end
<injekt> trololol
<slyphon> :)
<jmontross> ruby-1.9.2-p290 :030 > class Guy
<jmontross> ruby-1.9.2-p290 :031?> def speak(stuff)
<jmontross> ruby-1.9.2-p290 :032?> saying = "say #{stuff}"
<jmontross> ruby-1.9.2-p290 :033?> `#{saying}`
<jmontross> ruby-1.9.2-p290 :034?> end
<jmontross> ruby-1.9.2-p290 :035?> end
<jmontross> => nil
<jmontross> ruby-1.9.2-p290 :036 > Guy.speak(__method__)
<jmontross> NoMethodError: undefined method `speak' for Guy:Class
<jmontross> from (irb#1):36
<slyphon> jmontross: use a pastebin
<jmontross> we
<jmontross> why? it's less than 10 lines
<slyphon> 2-3 lines *maybe*
<injekt> jmontross: and the topic says less than 3 lines
<injekt> that's why
<jmontross> reasonable.
ryanf joined #ruby-lang
<jmontross> oh. nice
werwolf joined #ruby-lang
<jmontross> this needs to have self.speak instead of speak is all… ahh class vs instance method
<Banistergalaxy> jmontross: admit that you are high as a kite
<lianj> haha
<slyphon> :)
ivanoats joined #ruby-lang
<injekt> eh
<injekt> back to xmas shopping
* slyphon hits the JVM in the face with a shovel
<injekt> slyphon: jruby?
<slyphon> yeah
<slyphon> wlel
<injekt> memory consumption?
<slyphon> i'm testing my zookeeper bindings against the latest version of the jars and it's not going so good
<slyphon> just weird fits-and-starts
<jmontross> i don't get this whole __method__
<injekt> the jvm is nice, but you usually have to tweak the hell out of it for it to be nice
<slyphon> like an old man trying to pee
<injekt> jmontross: def foo; p __method__; end
<injekt> jmontross: foo
<headius> memory consumption schmemory schmonsumption
<injekt> ^
<slyphon> it's the name of the method you're in
<injekt> :D
<slyphon> headius: oh hai!
<headius> you don't have to tweak the jvm much for jruby to be nice
<headius> we do a lot of that ahead of time
<injekt> a wild headius appears
<slyphon> no, jruby is not giving me trouble
<jmontross> well i did that in the above pastie and it did not do anything
perryh_ joined #ruby-lang
perryh_ joined #ruby-lang
<slyphon> i read that "my favorite flags" blog post and took heed
<jmontross> i'm also not high. it is a weekday.
<injekt> jmontross: no you didn't
<injekt> jmontross: you didn't use __method__ inside of the method body
<jmontross> inject: true - i did not do the def foo; p __method__; end
pabloh joined #ruby-lang
<headius> hmm, have I had too much wine to wire instance variables up to invokedynamic....
<injekt> injekt* and yes, perhaps you should have :)
<injekt> headius: oh my
<slyphon> hah
<injekt> headius: I would like to say put the bottle down, but.. drink more and do more whacky things!
<headius> I do my best work under the influence
<slyphon> injekt: someone was telling me recently that one of the core MRI committers is *always* drunk while writing
<injekt> Don't we all :D
<injekt> apart from drivers
<injekt> that's a bad idea
<slyphon> indeed
<slyphon> Kids, Don't Drink and Drive
<deryl> hehe debugging under 1.9.3-p0 is funny. A) i have all the gems installed and bundled that my app depends on. B) when i run ruby --debug <command_im_debugging> (or prefixed with bundle exec) i get tons of cannot load such files and uninitialized constant errors. but the program runs even though it said it couldn't find the files it depends on.
<jmontross> okay- here is example of thte __method__ magicalness with a class method- http://pastie.org/2937006
<jmontross> thanks inject
<injekt> injekt*
<injekt> that's twice
<injekt> 3 strikes and..
<injekt> i dont know
<deryl> rubygems.rb:1252 - cannot load such file -- rubygems/defaults/ruby and rubygems/custom_require.rb:36 - cannot load such file -- pry
<jmontross> injekt me with your proper spelling
<jmontross> goodnight
<lianj> jmontross: puh and i thought my example was clear ;)
<slyphon> injekt: mockery?
<deryl> stuff like that. for the pry, i have the gem installed and regardless if i run ruby --debug or bundle exec ruby --debug it complains it cant find the gems. but if i run it without --debug it all runs fine.
<injekt> slyphon: exactly
<deryl> weird.
<slyphon> deryl: that might be gem debug output?
<slyphon> like, rubygems might be doing something lazy
<slyphon> that's causing a warning
<slyphon> i mean, i know you're supposed to run ruby w/ -w and shit, but man, that crap gets noisy and annoying
<jmontross> this could have all been avoided if I'd read higher on the thread. I started at "__method__" is magic.
<deryl> slyphon: i'm learning the debugger so not sure how to distinguish. https://gist.github.com/e4bdf984ffd22a1c42d3 is output from what i'm running
<slyphon> ah
<porcelina> injekt: i keep reading it inkjet. :D
<Xzyx987X> ok, as it turns out you can get the source code for a class in ruby: http://stackoverflow.com/questions/5587393/can-i-make-ruby-print-the-source-code-for-a-dynamic-method
<Xzyx987X> not sure if that's the direction I'll go in, but it's good to know
<jmontross> lianj - your example was clear though i took it out of concept as magic in no context… i imagined it to be more magical.
<injekt> porcelina: yeah most people do, even i do sometimes
<edwardsharp> omg, /nick dotmatrix
gregmoreno joined #ruby-lang
<jmontross> but that is really a cool variable : __method__
<porcelina> Xzyx987X: now i'm curious if there's something like save_lisp_and_die for ruby
<slyphon> edwardsharp: yeah, you should hear how much *less* noise injekt makes than that guy
livinded joined #ruby-lang
<injekt> haha
<injekt> lets agree all printers suck and none of them work
<edwardsharp> no way! i saw one work at the store once!
<slyphon> they work, but only when *they* want to
<slyphon> they are evil evil bastards
<injekt> the store ones work
<injekt> then you buy one
<injekt> and well, it doesn't
<edwardsharp> :D usb 6.66
<lianj> jmontross: def a; p [:methods, :instance_variables, :local_variables].map{|i| send(i).grep(:__method__) }; end; p a # :P
<lianj> jmontross: a hint: its a methods ;)
<jmontross> i luckily had a hash i defined as a earlier in my irb session
<jmontross> magical
<jmontross> you know some g ood magic tricks… what is this one called?
kitallis joined #ruby-lang
tallship joined #ruby-lang
zmack joined #ruby-lang
<injekt> :/
<injekt> if you're not in #ror, you missed the fun
jmontross left #ruby-lang
<shevy> injekt under linux, printers do indeed suck :(
<injekt> shevy: and if you're under windows, you have bigger problems
<ryanf> injekt: yeah? what fun?
<injekt> ryanf: I was referring to all of the 'injekt' related nick changes
<ryanf> ahh
<porcelina> Finished in 2.95 seconds
<porcelina> 68 examples, 30 failures
<porcelina> gggggg someone shoot me. =_=
<injekt> better than 50%!
<porcelina> that's just this service. ^_^
<porcelina> there's still a bunch that are at 0%
<lianj> at least there are tests to check
<shevy> injekt so far all printers I had worked under windows. I remember my canon i320 didn't have a linux printer some years ago, though a commercial driver was available... but paying like 30 euros just for software felt awkward given that that canon printer was super-cheap (like 50 euro or something in total)
<injekt> wall'o'text
<porcelina> there's tests to check because i wrote tests to check lol
<lianj> ^^
zedUNDginger joined #ruby-lang
jmcphers joined #ruby-lang
mitchty joined #ruby-lang
WillMarshall joined #ruby-lang
yumike joined #ruby-lang
ecin joined #ruby-lang
macmartine joined #ruby-lang
srbaker joined #ruby-lang
ecin_ joined #ruby-lang
<macmartine> What's the best Ruby book, for intermediate -> advanced?
ivanoats joined #ruby-lang
<bnagy> github
robbyoconnor joined #ruby-lang
ecin_ joined #ruby-lang
ecin_ joined #ruby-lang
<zedUNDginger> macmartine: refacotinr ruby edition puffy
ecin joined #ruby-lang
<macmartine> zedUNDginger: ok, i heard kinda bad things about that. but i'll take a look. thanks
<ryanf> haha
<ryanf> I have only heard good things about refacotinr
<ryanf> well, certainly no bad ones
<macmartine> i have the original Fowler Refactoring book and read somewhere that the Ruby edition was a Ruby edition that wasn't thoroughly thought out. But I don't remember the source so I'll take a gander
Defusal joined #ruby-lang
Defusal joined #ruby-lang
ksinkar joined #ruby-lang
yxhuvud joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
SuperTaz joined #ruby-lang
burgestrand joined #ruby-lang
JohnBat26 joined #ruby-lang
michael_mbp joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
srbaker joined #ruby-lang
kitallis joined #ruby-lang
thrcka joined #ruby-lang
mytrile joined #ruby-lang
bousquet joined #ruby-lang
zedUNDginger joined #ruby-lang
<yango> I expect to be missing something. I have an @array variable in my method.I want to implement each for the class that will return one element of the array at a time, the problem is I'm keeping a count of the next row to return, this feels awkward in Ruby, am I not missing something? I have def each; @cur_row += 1; yield @array[@cur_row]; end
<zedUNDginger> yango: def each: @array.each { |v| yield v }; end
<yango> then I could just do def each(&blk) @array.each &blk
<yango> no?
<zedUNDginger> yango: Yeah
<zedUNDginger> probably return 'self' after though
<yango> but, if I want to create an object from each item on the each call I would have to use the first idiom? { |v| yield Item.new(v) }
<yango> (or store the objects in the array in the first place)
paul0` joined #ruby-lang
<zedUNDginger> yango: ill be back soon im going to go buy some lollies to eat
Mchl joined #ruby-lang
gnufied joined #ruby-lang
zedUNDginger joined #ruby-lang
JohnBat26 joined #ruby-lang
nuclearsandwich joined #ruby-lang
woollyams joined #ruby-lang
publicvoid joined #ruby-lang
mytrile_ joined #ruby-lang
[zaf]-Coral joined #ruby-lang
ryanf joined #ruby-lang
solars joined #ruby-lang
kitallis joined #ruby-lang
robotmay joined #ruby-lang
skim1776 joined #ruby-lang
Wardrop_ joined #ruby-lang
burgestrand joined #ruby-lang
<edwardsharp> yes! i just got paid to install rvm!
* edwardsharp considers pledgie
dc5ala joined #ruby-lang
thrcka joined #ruby-lang
roadkith joined #ruby-lang
roadkith_ joined #ruby-lang
roadkith joined #ruby-lang
roadkith joined #ruby-lang
<shevy> edwardsharp ??? paid to install rvm? why?
<shevy> oh wait
<shevy> you mean, on another system or?
cyri_ joined #ruby-lang
<shevy> or do you mean on your system
<edwardsharp> um, on another system. i mean not so extraordinary that someone called me and was like, hey install rvm... but moreso like it was apart of this larger rails project that i bill time for...
molgrew joined #ruby-lang
<shevy> kkk
<shevy> now it makes a lot more sense
<edwardsharp> yeah, i'm usually rather convoluted...
<shevy> the best thing while coding is
<shevy> the getting-drunk part
pcwormald joined #ruby-lang
<shevy> and for proper motivation, you can only drink after you finished coding something small-ish
<shevy> like at least a method that does something useful
<Asher> at least during the ballmer peak
skim1776 left #ruby-lang
yorickpeterse joined #ruby-lang
<edwardsharp> Spaceghost: obviously.
apeiros|work joined #ruby-lang
<apeiros|work> good morning
<apeiros|work> I'm trying to compile ruby 1.9.2 on osx lion as 32bit, but I get a 64bit ruby instead.
<apeiros|work> I used: rvm_archflags="-arch i386" CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' rvm install ruby-1.9.2-n32bit
<apeiros|work> 9:24 AM
<apeiros|work> according to the information found on: http://beginrescueend.com/support/troubleshooting/
<apeiros|work> hints that I get a 64bit ruby instead: $ ruby -rrbconfig -e 'p :arch => RbConfig::CONFIG["arch"], :bignum => (1<<33).is_a?(Bignum)'
<apeiros|work> 9:25 AM
<apeiros|work> {:arch=>"x86_64-darwin11.2.0", :bignum=>false}
<apeiros|work> 9:35 AM
<Asher> check the actual flags in config.log
<Asher> also you can use file to check the type
<apeiros|work> meh, didn't notice that this irc client copies timestamps too - sorry
<Asher> "file ruby"
<apeiros|work> I already uninstalled it, recompiling now. but I'm pretty sure it's a 64bit version.
<apeiros|work> $ file ruby
<apeiros|work> ruby: Mach-O 64-bit executable x86_64
<apeiros|work> seems like I wasn't mistaken…
<Asher> well if it happens again see what actually got put in the makefile
<Asher> flag-wise
<apeiros|work> you know where rvm puts that?
<Asher> .rvm/source i think
<apeiros|work> .rvm/src ?
thone joined #ruby-lang
<Asher> yeah
<Asher> been a while since iv'e used rvm
srbartlett joined #ruby-lang
ryanf joined #ruby-lang
<apeiros|work> Asher, from the Makefile: "arch = x86_64-darwin11.2.0"
<apeiros|work> (sans quotes, of course)
zedUNDginger joined #ruby-lang
<edwardsharp> wait, how do you have 32bit lion?
<apeiros|work> edwardsharp, I don't
<apeiros|work> but lion is perfectly capable of running 32bit apps
<edwardsharp> but not so of 64bit ones?
<Asher> presumably there's a reason for 32 bit
<zedUNDginger> Asher: hey ash
<Asher> hey
<apeiros|work> Asher yes, stupid oracle is the reason
<apeiros|work> 64bit instant client segfaults, 32bit is reported to work fine on lion.
<apeiros|work> and while running a 32bit app on lion is fine, compiling a 32bit extension against a 64bit ruby is not…
<Asher> quality
GutenLinux joined #ruby-lang
pcwormald1 joined #ruby-lang
<apeiros|work> so any idea on how to get rvm to compile it with arch i386?
<apeiros|work> from grepping rvms source, I can't see anything suspicious, it seems to handle the rvm_archflags="-arch i386"…
<Asher> try passing it when you compile
<Asher> on the same line you invoke it with
<Asher> i had difficulty getting rvm to recognize environment settings but it worked fine when i passed them in explicitly
<apeiros|work> hm, so compile ruby by hand?
srbartlett joined #ruby-lang
<apeiros|work> or can I somehow get it still within rvm's env? because I'd like to be able to switch the rubies
<Asher> no
<Asher> rvm install … FLAG=...
<apeiros|work> so your suggestion is to replace the following line:
<apeiros|work> rvm_archflags="-arch i386" CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' rvm install ruby-1.9.2-n32bit
<apeiros|work> with:
thone joined #ruby-lang
<apeiros|work> FLAG="-arch i386" rvm_archflags="-arch i386" CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32' rvm install ruby-1.9.2-n32bit
<Asher> put them after the install not before
<Asher> but yes
<Asher> rvm install ruby-1.9.2-n32bit FLAG="-arch i386" rvm_archflags="-arch i386" CFLAGS='-m32' CXXFLAGS='-m32' LDFLAGS='-m32'
<edwardsharp> Place the following in your ~/.rvmrc file:
<edwardsharp> rvm_archflags="-arch i386"
<edwardsharp> wait, are you using rvm?
krz joined #ruby-lang
<apeiros|work> edwardsharp, looking at your link in a minute
<apeiros|work> edwardsharp, as stated, yes
<apeiros|work> asher, rvm doesn't seem to like that: ERROR: Unknown ruby interpreter string component: 'LDFLAGS='
<edwardsharp> oops, i meant rvmrc?
<Asher> look up how to pass rvm flags… it's in the manual somewhere
<Asher> i have to go to sleep now tho :)
<Asher> good luck w/it
<apeiros|work> Asher, thanks for your help
<apeiros|work> and yes, as per ther manual, it should be in front, see http://beginrescueend.com/support/troubleshooting/
<Asher> oh sorry then
<Asher> you were right :)
saLOUt joined #ruby-lang
<apeiros|work> edwardsharp, the link you pasted doesn't seem to contain information pertaining to my situation
<apeiros|work> putting the rvm_archflag into ~/.rvmrc instead of just passing it as an env variable didn't change anything
<edwardsharp> try without 'LDFLAGS'?
<apeiros|work> why should that change anything?
<edwardsharp> Unknown ruby interpreter string component: 'LDFLAGS='
<edwardsharp> ?
<apeiros|work> edwardsharp, that happens when I put the env vars at the end of the invocation
<edwardsharp> oh, so you get an error for every VAR declaration.
<edwardsharp> hmm.
<edwardsharp> what about in .rvmrc?
<apeiros|work> I doubt that'll change anything, it'll still be loaded as env vars. but lets see…
<apeiros|work> still Mach-O 64-bit executable x86_64
zmack joined #ruby-lang
<shevy> hmm
<shevy> load './test' # all works without .rb extension as the file name
<matti> Asher: :-)
<shevy> load 'test.rb' also works
<shevy> load 'test' however does not work hmm
robotmay joined #ruby-lang
sepp2k joined #ruby-lang
Banistergalaxy joined #ruby-lang
jensn joined #ruby-lang
adambeynon joined #ruby-lang
tijmencc joined #ruby-lang
Diaoer joined #ruby-lang
yorickpeterse joined #ruby-lang
benanne joined #ruby-lang
workmad3 joined #ruby-lang
tijmencc joined #ruby-lang
yorickpeterse1 joined #ruby-lang
kitallis joined #ruby-lang
heftig joined #ruby-lang
[zaf]-Coral joined #ruby-lang
yfeldblum joined #ruby-lang
ksinkar_ joined #ruby-lang
workmad3_ joined #ruby-lang
dave_miles joined #ruby-lang
misconosciuto joined #ruby-lang
<shevy> hmmmm
<shevy> when I have a method that does not exist
<shevy> for instance, blablablablabllalala() in a file that is required
<shevy> ruby stops loading that file
<shevy> all code stuff that is "seen" before that invalid call can however be used
<shevy> I can rescue the error too: rescue NameError => error
<shevy> but I can't continue loading that file
<shevy> Is it somehow possible to say "Ok, that's an invalid call ... but we rescued it anyway, silently, and we continue reading the rest of the ruby file in question no matter what." ?
<apeiros|work> not like that, no
<apeiros|work> you can use some method_missing hack to ignore the missing method call, or you can use eval + the backtrace
<apeiros|work> but those are both ugly hacks
* apeiros|work gotta switch networks, off for now
yfeldblum joined #ruby-lang
<shevy> hmm
<shevy> if I wouldn't hate eval so much ... :(
<erikh> the hate is healthy, the pragmatist should know when to use it though.
<yfeldblum> eval is evil; why do you hate it?
<erikh> heh
<shevy> I find all the eval*s to be really ugly to read and look at.
<erikh> not sure how you expect to get any better if you avoid the ugly things
<shevy> ok
<shevy> every time I use @@ from now on, I will comment it with # erikh thinks this is good
<erikh> no, don't misread what I said
<erikh> judicious use of something just acknowledges that it's the appropriate technique for a particular task
<Banistergalaxy> Eval is my friend
<erikh> that doesn't mean it's pretty, or ugly. those constructs exist for a reason and better to learn and understand what those cases are than fear and avoid them because they aren't furry, small and soft
<Banistergalaxy> Erikh hello erik
<erikh> Banistergalaxy: hi hi
<andrewvos> erikh: Except flip flops
<erikh> andrewvos: haha ok
<andrewvos> :)
<erikh> I mean you only have to see so many painfully slow abuses of #inject before you start going "why the fuck doesn't this guy know how to use #each"
<andrewvos> erikh: Yeah :( It's like salt. Use it sparingly and you have a wonderful meal. Too much of it though, and you die a painful salt death. I think.
<erikh> heh
<erikh> yes
<erikh> painful death by functional programming in a non-tail-call language
<andrewvos> Starting to think I haven't had much sleep
<erikh> welcome to my week
<Banistergalaxy> Hello andrewvos
<erikh> we have guests this week. I love having them over but it tends to keep me on my toes.
<andrewvos> Banistergalaxy: Hey :)
<andrewvos> erikh: :(
<erikh> that and the additional booze quotient is making me crash a lot earlier, ergo up at 2am ready to work
<erikh> oh it's not bad, just not sleeping very much is all.
<Banistergalaxy> Andrewvos are you a scrapper
<andrewvos> Banistergalaxy: A fighter?
<erikh> Banistergalaxy: what was that LALR you sent me earlier? you sent it to me as I was packing up for the day
<Banistergalaxy> Yeah.
<andrewvos> Banistergalaxy: No
<andrewvos> Banistergalaxy: Why?
<Banistergalaxy> Andrewvos I'm a scrapper
<andrewvos> Banistergalaxy: Erm ok
<Banistergalaxy> Erikh Yeah it looks cool
<erikh> what was the url?
<bnagy> is there a slick way to get whatever class is implemented in a given file and assign it to a var?
<yfeldblum> ruby has tail calls ... they're just not optimized!
<erikh> yfeldblum: heh.
<andrewvos> I mean it's silly and all
<zedUNDginger> erikh: there you go erik https://github.com/d11wtq/whittle
<andrewvos> But that had me laughing for a bit
<erikh> wow, successful troll
<erikh> very successful given the number of retweets
<erikh> zedUNDginger: that's pretty freakin' neat
<erikh> great docs too
<shevy> and no eval!
tijmencc joined #ruby-lang
<bnagy> hrm
<bnagy> so so basically I have a thing which reads a YAML config file
<bnagy> and one of the things I need to be able to specify is a class or a module or something which is stored in a file
<bnagy> like it's a user specified hook class thing that does stuff
takaokouji joined #ruby-lang
<bnagy> I can have the user store the code as, say, YAML and then load it, but that seems weird
srbartlett joined #ruby-lang
takaokou_ joined #ruby-lang
tijmencc_ joined #ruby-lang
<bnagy> I can mandate the class name, then have the file it's in in the config
<bnagy> but that's a bit ugly
tijmencc joined #ruby-lang
srbartlett joined #ruby-lang
tijmencc joined #ruby-lang
y3llow joined #ruby-lang
retro|cz joined #ruby-lang
cynosure joined #ruby-lang
Manhose joined #ruby-lang
burgestrand joined #ruby-lang
looopy joined #ruby-lang
burgestrand joined #ruby-lang
tijmencc_ joined #ruby-lang
tijmencc_ joined #ruby-lang
tijmencc_ joined #ruby-lang
tijmencc joined #ruby-lang
tijmencc_ joined #ruby-lang
tijmencc joined #ruby-lang
tijmencc joined #ruby-lang
toretore joined #ruby-lang
vereteran joined #ruby-lang
<manveru> YAML is the XML of ruby...
<Tasser> manveru, it's at least less nosy
statim joined #ruby-lang
<shevy> XML carries so much </closing_tag> information overhead
<statim> just curious if anyone knows anything about this. im now on 1.9.3p0 and it takes about 15 seconds to load my rails environment. lots of old talk about this with 1.9.2 and require's, but supposedly the fix was in 1.9.3. so now im not sure what could be going on. anyone heard anything that might help me find a solution?
<rane_> is it faster than on 1.9.2?
JohnBat26 joined #ruby-lang
<statim> rane_: not really, times range between 14-16s for each.. maybe this is lower more consistently, but they feel the same
dinesh_ joined #ruby-lang
RomD`` joined #ruby-lang
roadkith joined #ruby-lang
<manveru> that means you're not using 1.9.3
tijmencc joined #ruby-lang
workmad3 joined #ruby-lang
<yfeldblum> the 1.9.3 patch to require made it a little more efficient, but did not give $: a fast #include?
tijmencc_ joined #ruby-lang
Pip joined #ruby-lang
mytrile joined #ruby-lang
yorickpeterse1 joined #ruby-lang
tijmencc joined #ruby-lang
tijmencc_ joined #ruby-lang
roadkith joined #ruby-lang
roadkith joined #ruby-lang
roadkith_ joined #ruby-lang
roadkith joined #ruby-lang
Guedes joined #ruby-lang
<muzone> manveru: u there man?
Pip joined #ruby-lang
Pip joined #ruby-lang
<troubleman> he's ignoring you muzone
<muzone> nah can't be man, this guy's always been nice to me
wyhaines joined #ruby-lang
<erikh> I don't think manveru has a mean bone in his body
<erikh> he's probably just busy.
workmad3 joined #ruby-lang
tijmencc joined #ruby-lang
mark_locklear joined #ruby-lang
shevy joined #ruby-lang
burgestrand joined #ruby-lang
tommyvyo_ joined #ruby-lang
looopy joined #ruby-lang
<deryl> manveru is more of a christmas bear. i don;t think the guy *knows* how to be mean
malev joined #ruby-lang
<manveru> heh
<shevy> fat like one
<manveru> muzone: yeah, sorry, we're moving
<shevy> and he is always moving!!!
j`ey joined #ruby-lang
<yorickpeterse> He must be on the run
<shevy> every 2 months
<j`ey> seems like there is an index method, on Arrays, to return the index of a particular item
<j`ey> how do I actually return the item
<j`ey> im sure there used to be Array#find?
<manveru> used to be?
<yorickpeterse> By index?
<j`ey> using a block
<yorickpeterse> Eh. Array#select
<manveru> >> [5,6,7].find{|e| e > 6 }
<manveru> => 7
<yorickpeterse> That might be it, otherwise Array#map
<j`ey> oh hm
<manveru> it's in Enumerable
<j`ey> oh ok
<manveru> muzone: so, you still on the sqlite thing?
<shevy> he switched to LSD
zedUNDginger joined #ruby-lang
deryl joined #ruby-lang
<muzone> manveru: Yes sir!
io_syl joined #ruby-lang
io_syl joined #ruby-lang
tijmencc_ joined #ruby-lang
tomzx joined #ruby-lang
zedUNDginger joined #ruby-lang
Spooner joined #ruby-lang
yalue joined #ruby-lang
sakamal joined #ruby-lang
achamian joined #ruby-lang
saLOUt joined #ruby-lang
gnufied joined #ruby-lang
<oddmunds> muzone: still working on the prayertimes stuff?
<muzone> oddmunds!
<muzone> how are u man good to see you :)
<muzone> yes i am, taking a little break right now though..
<muzone> ill be back to waterboard y'all in notime though hehe
DotMH joined #ruby-lang
<troubleman> can't wait :)
<troubleman> coolest thing in #ruby-lang since that dude tried making that time machine
sakamal_ joined #ruby-lang
<muzone> uh
<muzone> oddmunds: so yeah what you up to these days?
<oddmunds> all sorts of stuff. among other things i'm looking into Rails.
<muzone> ah nice
tijmencc joined #ruby-lang
<oddmunds> yeah, I guess it's time to find out what all the fuzz is about.
tijmencc_ joined #ruby-lang
<muzone> indeed
<oddmunds> Rails was my first encounter with Ruby many years ago, but I didn't like it because I didn't understand what was going on at all.
<muzone> its kinda like the california gold rush i guess
<muzone> great opportunities
<oddmunds> So when i got into Ruby later I didn't pay Rails any attention.
<muzone> hehe
<muzone> yeah i guess rails is the reason most of us are here in the first place..
<oddmunds> I'm not so sure of that.
<muzone> maybe not
<muzone> at least the reason why the two of us are here, to put it like that
<oddmunds> Rails probably is an awesome framework, but Ruby is a super awesome language in itself.
<muzone> no doubt no doubt!
<oddmunds> muzone: no, I'm here because of Ruby.
<oddmunds> I haven't even looked properly at Rails until yesterday.
knu joined #ruby-lang
robbrit joined #ruby-lang
<muzone> oddmunds: so what site are you looking to put up?
felipegb joined #ruby-lang
<muzone> oddmunds: ooh also peep http://www.stillwellaudio.com/
<oddmunds> muzone: you use Reaper?
<muzone> no, you? heard good things about it though. pretty much an ableton kid myself..
robbrit left #ruby-lang
<muzone> ever since i saw jazzy jeff from fresh prince talk about how cool it was (http://www.ableton.com/pages/artists/dj_jazzyjeff) and seeing all my favorite producers abandoning reason over it, i had to check it out
<muzone> since then it's been an amazing journey
<deryl> friend gave me his copy of ableton because he's going to Reason. (why, idk) - I'd like to learn Ableton
<muzone> go for it bro :)
<muzone> when he hears the shit you're able to cook up with it, he's gonna want that copy back in notime
<muzone> make sure you get the live library too though, that's where all the secrets are imho
<deryl> nice
Pip joined #ruby-lang
<jbwiv_> guys, I'm trying to track down in a rails app where an object is persisted to the database....it's wrapped deeply in libraries. I was thinking about using set_trace_func and passing a method which would match on method name save, or something similar. have any better ideas?
<oddmunds> muzone: i'm not really learning Rails because of any site idea. i'm just curious.
Tref joined #ruby-lang
tijmencc joined #ruby-lang
fvollero joined #ruby-lang
segy joined #ruby-lang
Jade joined #ruby-lang
tijmencc_ joined #ruby-lang
dv310p3r joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
Tref joined #ruby-lang
Sailias joined #ruby-lang
gnufied joined #ruby-lang
dv310p3r joined #ruby-lang
yorickpeterse1 joined #ruby-lang
dave_miles joined #ruby-lang
pcwormald1 joined #ruby-lang
cyri_ joined #ruby-lang
solars joined #ruby-lang
setmeaway joined #ruby-lang
comboy joined #ruby-lang
znz_v joined #ruby-lang
dkannan joined #ruby-lang
locks joined #ruby-lang
corecode joined #ruby-lang
ohsix joined #ruby-lang
mitchty joined #ruby-lang
imajes joined #ruby-lang
kmeehl joined #ruby-lang
gnufied joined #ruby-lang
rippa joined #ruby-lang
<darix> jbwiv_: how about just overwriting the save method?
<darix> alias the old one away. put yours in place and call old aliased method
jwill joined #ruby-lang
slyphon joined #ruby-lang
leonL joined #ruby-lang
pcwormald joined #ruby-lang
nofxx joined #ruby-lang
<jbwiv_> darix, I've tried that....somehow it still gets persisted. in fact, overwriting save used to work in rails 2.x, but in rails 3.1 something has changed
fayimora joined #ruby-lang
<jbwiv_> I even believe it worked in rails 3.0
<jbwiv_> the save gets triggered by an assignment on an association. I essentially want to clone an object, assign an existing object to its association, but prevent any save. the object is purely used for simulation and not necessary to save in this case
outoftime joined #ruby-lang
achamian joined #ruby-lang
MistyM joined #ruby-lang
tris joined #ruby-lang
bruegel joined #ruby-lang
<Sailias> jbwiv_: i haven't seen the entire discussion, but it looks like you actually want to use the clone method
<Sailias> not sure if that has been suggested
<jbwiv_> Sailias, yes, I'm aware of that method. problem is saves still get triggered in activerecord. I want to clone the objects, use existing code which is contained within, but prevent all saves to the database
<Sailias> jbwiv_: it must be something you are doing. There is no reason why rails 3.1 would cause @parent.children.build to save
<Sailias> jbwiv_: or are you saying you want to clone an object (which works) but then make the object "unsavable" ?
io_syl joined #ruby-lang
io_syl joined #ruby-lang
retro|cz joined #ruby-lang
<jbwiv_> Sailias, A has_one B. if I clone an object of A, and then call obj.b = B.new, after_update callbacks get triggered in B, which leads me to believe both objects are getting persisted
<jbwiv_> Sailias, yes, making it unsavable would likely do the trick
<Sailias> jbwiv_: it is the has_one that is messing with you
<jbwiv_> Sailias, yes. I even tried has_one :b, :autosave=>false, but no love
<Sailias> jbwiv_: i believe that saying obj.b = B.new is doing the assignment. You need to use obj.build_b()
<Sailias> the brackets are for the attributes of course, i'm not writing java
<jbwiv_> Sailias, well, sorry, my example is misleading. I really need to do obj.b = B.find(params)
<jbwiv_> so b will already exist in the db
outoftime joined #ruby-lang
<jbwiv_> but I wish to assign it to the clone
<jbwiv_> obj looks at the fields of b to determine certain logic decisions while running the simulation
<Sailias> jbwiv_: so then obj.build_b(B.find(id).attributes)
<jbwiv_> but uses it for nothing more than that
<jbwiv_> Sailias, ah...k. let me try that
macmartine joined #ruby-lang
<jbwiv_> Sailias, still somehow triggering a save. when I try the above, I get "ActiveRecord::RecordNotSaved: Failed to remove the existing associated vessel. The record failed to save when after its foreign key was set to nil."
<Sailias> jbwiv: are you able to gist some code?
<Sailias> jbwiv_: ^
<jbwiv_> Sailias, let me think how I can. it's pretty involved code...the models are heavy
<Sailias> jbwiv_: i'll survive
<jbwiv_> Sailias, give me a min
<Sailias> jbwiv_: k
<jbwiv_> Sailias, pm'd you the gist
heftig joined #ruby-lang
<jbwiv_> Sailias, search for clone in that gist
<jbwiv_> c.build_vessel triggers the save in the current iteration
<jbwiv_> tried changing it to c.build_vessel(vessel.clone.attributes) but no luck there either
flip_digits joined #ruby-lang
<Sailias> ok, give me 2 mins to look it over
<jbwiv_> Sailias, sure thing...thanks
tbuehlmann joined #ruby-lang
<Sailias> jbwiv_: i'll continue this in PM
rayners joined #ruby-lang
malev joined #ruby-lang
jondot joined #ruby-lang
<jondot> anyone happen to work with SQS and some kind of workers in ruby? kinda like resque with SQS backend?
plusk joined #ruby-lang
jensn joined #ruby-lang
andrewhl joined #ruby-lang
slyphon joined #ruby-lang
rolfb joined #ruby-lang
lsegal joined #ruby-lang
Neil joined #ruby-lang
Wardrop joined #ruby-lang
fayimora joined #ruby-lang
wyhaines joined #ruby-lang
cjs226 joined #ruby-lang
Enlik joined #ruby-lang
rtl joined #ruby-lang
<slyphon> drbrain: yo
<slyphon> drbrain: wanted to bring your attention to http://rubyforge.org/pipermail/rubygems-developers/2011-October/006838.html
<slyphon> i think this would be a big win for jruby, and i think the people discussing it misunderstood the use-case
Diaoer joined #ruby-lang
dejongge joined #ruby-lang
scottschecter joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
joast joined #ruby-lang
gearaholic joined #ruby-lang
cynosure joined #ruby-lang
kain joined #ruby-lang
<rue> slyphon: That's unpossible!
<slyphon> hah
<darix> slyphon: just an idea... maybe extend the dependency validator in the rubygems.org web app to check those maven depencencies
Pip joined #ruby-lang
<slyphon> it seems like the guys in that thread really didn't understand what was being suggested
<slyphon> darix: that'd be great
<slyphon> how?
vereteran joined #ruby-lang
<slyphon> ffs, srsly?
<slyphon> OF COURSE
<darix> what?
<slyphon> nothing, i was kicking myself for not just guessing that
srbaker joined #ruby-lang
nuclearsandwich joined #ruby-lang
<rue> Still have to sell the idea
<rue> erikh: slyphon's going to javafy Rubygems, OK?
<slyphon> i was simply trying to +1 headius' idea
<slyphon> (and not in the google+ way, because i actually wanted someone to see it)
<rue> Nope, sorry, you're the man now
vereteran joined #ruby-lang
akahn joined #ruby-lang
timbleck joined #ruby-lang
simon_weber joined #ruby-lang
<Spooner> Anyone able to shed any light on why webrick is breaking for me? https://gist.github.com/1405413 (I'm on a VM and I am a Linux-noob, so I can accept that it is probably something I've set up wrong).
<erikh> rue: eh, I don't work on it much anymore
<erikh> I'm kind of pro-headius-maven-gems
dkannan joined #ruby-lang
RickHull joined #ruby-lang
Manhose joined #ruby-lang
locks joined #ruby-lang
beawesomeinstead joined #ruby-lang
cesario joined #ruby-lang
mccraig_ joined #ruby-lang
Jake232 joined #ruby-lang
robbrit joined #ruby-lang
abuiles joined #ruby-lang
dnyy joined #ruby-lang
gnufied joined #ruby-lang
cldwalker joined #ruby-lang
whoops joined #ruby-lang
mrchrisadams joined #ruby-lang
Pip joined #ruby-lang
<andrewvos> :(
<andrewvos> So I'm getting some encoding issue trying to PUT data with restclient to sinatra.. Would a good approach be to force_encoding?
comboy joined #ruby-lang
corecode joined #ruby-lang
zetesha joined #ruby-lang
bryanl joined #ruby-lang
looopy joined #ruby-lang
apeiros_ joined #ruby-lang
zetesha joined #ruby-lang
scampbell joined #ruby-lang
plusk joined #ruby-lang
<darix> andrewvos: what mime type does the client set for the put?
yorickpeterse1 joined #ruby-lang
<andrewvos> darix: Very good point. I'm not setting one.
RomD`` joined #ruby-lang
kitallis joined #ruby-lang
<andrewvos> darix: Thanks :)
Wardrop joined #ruby-lang
burgestrand joined #ruby-lang
butchanton joined #ruby-lang
perryh joined #ruby-lang
perryh joined #ruby-lang
FrostyAcres joined #ruby-lang
plusk joined #ruby-lang
RickHull joined #ruby-lang
<darix> welcome
zetesha joined #ruby-lang
<devn> What's the idiomatic way to "refer" a specific method from another module without referring all of them?
<devn> For instance, a method is somewhere else, jumbled up with a whole bunch of other methods. I want one specific method from that module.
<apeiros_> you mean you want something like include, but only for that single method?
<devn> apeiros_: exactly.
<apeiros_> nocando afaik
workmad3 joined #ruby-lang
<devn> Not even with some crazy magic metaprogramming? ;)
<apeiros_> I'm not aware of any. you might be able to do it with some crazy bit of C programming.
<devn> apeiros_: what about adding some structure around the method in question? I suppose that still doesn't negate the need for some specific include.
<devn> apeiros_: yeah, we're not going there, not today anyway. :)
Swimming_Bird joined #ruby-lang
<Spooner> extend Forwardable; def_delegators :OtherModule, :some_method, :other_method
<apeiros_> you can put the method in question into its own module and include only that
<apeiros_> Spooner: that'd require it to be a class method, no?
<apeiros_> (on OtherModule)
Swimmin__ joined #ruby-lang
<Swimmin__> if i subclass array, how can i make it so collect/select/etc return an object of the subclass instead of Array
<Spooner> Yes, and then place it as an instance method on ThisModule, so yeah, pointless (but you could put it on ThisModule's metaclass, I guess). Yeah, won't work will, it?
<steveklabnik> don't subclass array.
<steveklabnik> delegate
<steveklabnik> subclassing core objects leads to subtle bugs
<devn> and trace amounts of awesome when used with care
<devn> ;)
<Swimmin__> well delegating for sure it won't return an object of the same class
<apeiros_> subclass array? did I miss something…
<steveklabnik> it's your funeral.
<steveklabnik> Swimmin__: why not? it certainly could.
<devn> steveklabnik: why the doom and gloom?
<apeiros_> ah, other question
* apeiros_ goes with steveklabnik - don't subclass
<Swimmin__> i'd have to manually override every/most enumerable method
<steveklabnik> devn: because seriously, MRI cheats in the C
<steveklabnik> Swimmin__: no, you just implement each and mix in Enumerable
<Swimmin__> hrm
<devn> steveklabnik: I...did not know that. What would you qualify as cheating?
<Swimmin__> ok
<steveklabnik> devn: for example, if you subclass String, and rely on behvior in initialize, sometimes, when MRI creates a string, it does not call String#initialize
<steveklabnik> sooo you're fucked.
<steveklabnik> this is For Performance.
<Swimmin__> so DelegateClass(Array) and implement each such that it returns my same class, then mixing in enumerable willd o the rest
<devn> steveklabnik: Can we get some double quotes and a (tm) at the end of "For Performance"(tm)
<steveklabnik> i prefer to just write out the single method missing, but sure.
<steveklabnik> devn: :D
<apeiros_> devn: ™
<Swimmin__> ick, i hate method_missing
<devn> you used a constant. For Performance(TM)
<steveklabnik> gives you a start.
<steveklabnik> that will return arrays though
<Swimmin__> doesn't let you do respond_to? or tab completion in irb, or etc.
<Swimmin__> but thanks for the help
<devn> how about pry?
<steveklabnik> so you modify method_missing to re-wrap it: http://pastie.org/2939742
<devn> pry. i like pry. (think of me saying that like "I like pie")
<steveklabnik> (and of course, implement respond_to? as well.
<devn> anyway, lunch time, thanks for that info on subclassing. I wasn't aware of that.
<devn> happy rubying
<steveklabnik> devn: cheers
<steveklabnik> devn: stdlib is fine, just core
<Swimmin__> basically anything written in c?
<rippa> stepnem: class.new ?
<steveklabnik> Swimmin__: yes.
<steveklabnik> you are free of course to audit the source and make sure it has the semantics you wish. heh.
<steveklabnik> the worst part is that it will work the vast majority of the time.
<steveklabnik> but that 5%....
<RickHull> Swimmin__: you should implement respond_to? when you use method_missing. there may be an alternate form that takes care of both
<RickHull> generally, call super at the end of your respond_to? impl
<rippa> steveklabnik: class.new ?
<Swimmin__> if you have expected methods i'd rather implement those methods
<burgestrand> Use respond_to_missing? instead if you’re on 1.9
<steveklabnik> rippa: what about it?
<rippa> shouldn't it maybe be Class.new ?
<Swimmin__> i feel like method missing is for when you explicitly want to accept arbitrary strings
<steveklabnik> rippa: no, you want a new delegator.
<steveklabnik> Swimmin__: nope, it's for dynamic dispatch.
ecin_ joined #ruby-lang
<steveklabnik> but whatevs.
<steveklabnik> :)
<apeiros_> for things like that, I prefer class_eval
<apeiros_> but then again, I'm a premature optimizer!
<RickHull> in other words, stateful dispatch -- depending on the state of the object?
<rippa> steveklabnik: dunno, class.new just gives me syntax error
<Swimmin__> have to do self.class.new
<steveklabnik> rippa: might have to do self.
<rippa> that makes sense
<steveklabnik> apeiros_: i prefer to use class_eval inside my method_missing. ;) (I dont really)
<rippa> cause class is a keyword
<steveklabnik> rippa: ahhh yeah. derp. heh.
<apeiros_> classy
<steveklabnik> take the hit the first time, make it work fast the rest of the time.
ilyam joined #ruby-lang
QaDeS joined #ruby-lang
phlipper joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
benanne joined #ruby-lang
srbaker joined #ruby-lang
darkf joined #ruby-lang
<rue> class Funeral < Array; end
<steveklabnik> :)
<apeiros_> class Cloud7 < Funeral; end
<apeiros_> or wait, is the idiom "cloud 9" in english?
<rippa> what idiom?
<apeiros_> when you're very happy, you say "I'm on cloud 9", that one
<apeiros_> in german it's "Auf Wolke 7"
brianpWins joined #ruby-lang
<rippa> apeiros_: seventh heaven
<rippa> in russian we say "seventh sky"
<apeiros_> interesting
<apeiros_> thanks
<apeiros_> hm, though we've got 7th heaven too… means the same
<rippa> cloud nine works too
<rue> Cloud 9 or 7th heaven
<shevy> Cloud 7!!!
<rue> På engelska
<rue> Cloud 7 is for losers
<shevy> humpa humpa!
michael_mbp joined #ruby-lang
<Swimming_Bird> steveklabnik: had to do something like this to get method_missing working: http://pastie.org/2939865
<Swimming_Bird> unless you can think of a better way
nofxx joined #ruby-lang
<steveklabnik> ahhh yeah. probably not a better way.
<Swimming_Bird> i'd still like to think of a way to get it to work using DelegateClass, but haven't been able to.
<Swimming_Bird> seems like enumerable loves to return arrays rather than self
saysjonathan joined #ruby-lang
<rue> Enumerable is defined in terms of #each, not self
sepp2k joined #ruby-lang
<manveru> >> ObjectSpace.each_object(Class).select{|c| c < Enumerable }
<manveru> => [Enumerator::Generator, Enumerator, Struct::Tms, Dir, File, ARGF.class, IO, Range, Struct, Hash, Array, IRB::DefaultEncodings]
<manveru> doesn't make a whole lot of sense for most
<Swimming_Bird> rue: even when i have each return an object of the new class, collect/select/etc still return an array
<apeiros_> Swimming_Bird: of course, why would Enumerable care about what your each returns?
<apeiros_> Enumerable works off of each yielding stuff
<apeiros_> it can't possibly use the return value
elux joined #ruby-lang
<Swimming_Bird> yah, i wouldn't think so, but how is it possible to make enumerable return an object of class self instead of array. i haven't been able to figure one out yet
<apeiros_> it isn't
<manveru> because it's not possible
<apeiros_> you have to wrap the method
<manveru> or reimplement it
<apeiros_> def select(&block); cast_to_your_class(super); end
<apeiros_> -&block
towski joined #ruby-lang
achamian joined #ruby-lang
robotmay joined #ruby-lang
dv310p3r joined #ruby-lang
malev joined #ruby-lang
Carnage\ joined #ruby-lang
mark_locklear joined #ruby-lang
michael_mbp_ joined #ruby-lang
kitallis joined #ruby-lang
michael_mbp_ joined #ruby-lang
scampbell joined #ruby-lang
ecin joined #ruby-lang
ilyam_ joined #ruby-lang
mrsolo joined #ruby-lang
saLOUt joined #ruby-lang
michael_mbp_ joined #ruby-lang
jmontross joined #ruby-lang
robbyoconnor joined #ruby-lang
workmad3 joined #ruby-lang
rayners joined #ruby-lang
michael_mbp joined #ruby-lang
phlipper joined #ruby-lang
Pip joined #ruby-lang
michael_mbp_ joined #ruby-lang
mytrile joined #ruby-lang
Pip joined #ruby-lang
saLOUt joined #ruby-lang
[zaf]-Coral joined #ruby-lang
Pip joined #ruby-lang
Pip joined #ruby-lang
Manhose joined #ruby-lang
nuclearsandwich joined #ruby-lang
Banistergalaxy joined #ruby-lang
solars joined #ruby-lang
porcelina joined #ruby-lang
ilyam joined #ruby-lang
scampbell joined #ruby-lang
ilyam joined #ruby-lang
leonL joined #ruby-lang
ivorybishop joined #ruby-lang
<Swimming_Bird> anyone know of any libraries to puts a grid?
<Swimming_Bird> err table
zmack joined #ruby-lang
<rue> HTML!
nlindstrom joined #ruby-lang
<Swimming_Bird> well it's for a cli util
musl joined #ruby-lang
srbartlett joined #ruby-lang
jwill joined #ruby-lang
<rue> You can use curl
curtism joined #ruby-lang
solars joined #ruby-lang
srbaker joined #ruby-lang
<Swimming_Bird> lol
nlindstrom joined #ruby-lang
cesario joined #ruby-lang
nlindstrom joined #ruby-lang
kitallis joined #ruby-lang
DRCALKIN joined #ruby-lang
<rue> What?
<rue> Actually I'm pretty sure a gem for such was just mentioned
<heftig> Swimming_Bird: should be relatively easy, actually
<rue> Just ~ recently
<Swimming_Bird> yah, i'm sure it is. thats why i figured there was a good gem for it already
simon_weber joined #ruby-lang
<Swimming_Bird> rupert is so huge though. does html/pdf/images/graphs
<bougyman> .31
<MistyM> Swimming_Bird: Haven't tried that part, but take a peek at the ansi gem's Table class?
<rue> bougyman: I'll offer .40
<MistyM> Oh, or that. That looks extremely simple.
beawesomeinstead joined #ruby-lang
<rue> Swimming_Bird: It's all about the google-fu. Or duck-fu in this case :)
<Swimming_Bird> yah, i did google it believe it or not. but couldn't find anything useful
ryanf joined #ruby-lang
malev joined #ruby-lang
<Swimming_Bird> i wonder if that library supports stripping out invisible characters (coloring) for calculation of widht
dr_bob joined #ruby-lang
mccraig joined #ruby-lang
fridim_ joined #ruby-lang
livinded joined #ruby-lang
nothingsTrivial joined #ruby-lang
<Swimming_Bird> ansi gem looks pretty sweet for this
<heftig> Swimming_Bird: https://gist.github.com/1406286
dnyy joined #ruby-lang
<heftig> took me less than 15 minutes, mostly untested though
zedUNDginger joined #ruby-lang
whoops joined #ruby-lang
cldwalker joined #ruby-lang
looopy joined #ruby-lang
Sailias_ joined #ruby-lang
Manhose joined #ruby-lang
<rue> Swimming_Bird: Ah, that's the one that was mentioned
tbuehlmann joined #ruby-lang
twittard joined #ruby-lang
tommyvyo_ joined #ruby-lang
jensn joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
Carnage\ joined #ruby-lang
Manhose_ joined #ruby-lang
Banistertab joined #ruby-lang
akahn joined #ruby-lang
looopy joined #ruby-lang
<andrewvos> Banistertab: Seen any good movies lately?
robbrit left #ruby-lang
<Banistertab> Andrewvos watch drive
<Banistertab> Andrewvos still playing skyrim?
<muzone> andrewvos: dagvaktin, naturvaktin and fangavaktin from iceland is the comedy of the year in my book ;)
<muzone> one of the lead actors even became the mayor of reykjavik because of it
workmad3 joined #ruby-lang
<andrewvos> Banistertab: Yeah a little
<andrewvos> Banistertab: Drive doesn't sound like something I want to watch
<Banistertab> Andrewvosnot into it anymore?
<andrewvos> muzone: Hmm
<andrewvos> Banistertab: No I am... Just can't play it all my life :)
<RickHull> Melancholia is a good movie. haunting...
ilyam_ joined #ruby-lang
<andrewvos> RickHull: Banistertab suggested that to me actually, which is why I now ask him for movie recommendations :)
<RickHull> Lars Von Trier of the Dogme95 movement. though it's not in the dogme tradition. in fact, my biggest complaint is the faux-shaky camerawork
havenn joined #ruby-lang
<RickHull> ha, nice
<Banistertab> Andrevosyouve sen moon rigt?
<andrewvos> RickHull: I enjoy the camera work actually :)
<andrewvos> Banistertab: Yeah I have
<RickHull> the cinematography was generally wonderful, but the shaky camerawork was unnecessary and generally distracting imho
looopy joined #ruby-lang
<RickHull> there were lots of steady shots as well
<Banistertab> Andrewvos have you seen the color trilogy, rouge, bleu, blanc
<havenn> Banistertab: Ooooh, love those movies.
<andrewvos> Banistertab: I have not.
<Banistertab> I thi kyoud like that
<Banistertab> Havenn yeah and the bonus of a young juliette binoche
<havenn> Banistertab: Makes me want to ride in a suitcase on a plane, get a ham radio, and an esspresso with ice cream. Indeed.
<Banistertab> Oh and also che k out unbearable ligt ess of being
<Banistertab> Lightness
<andrewvos> Banistertab: http://www.imdb.com/title/tt0111495/ <--?
thrcka joined #ruby-lang
<Banistertab> Havenn gave you seen unbearable ligtness?
<havenn> Banistertab: Nope.
<RickHull> Banistertab: you're driving, aren't you? ;)
<Banistertab> Andrewvos yes
<Banistertab> Rickhull pulled over hehe but tping on tab is hard
<Banistertab> But i am in my car yes
<Banistertab> Bbl
kedare joined #ruby-lang
havenn joined #ruby-lang
amerine joined #ruby-lang
voker57 joined #ruby-lang
voker57 joined #ruby-lang
wilkie joined #ruby-lang
workmad3 joined #ruby-lang
havenn joined #ruby-lang
mytrile joined #ruby-lang
saLOUt_ joined #ruby-lang
edwardsharp joined #ruby-lang
brianpWins joined #ruby-lang
onio joined #ruby-lang
<onio> hi, I am new to ruby, I come from c++, is there a kind of "man" command for ruby ? to access function documentation ?
<lianj> ri
<yorickpeterse> As lianj said, ri. `ri Array#length` for example
<onio> into the irb console ?
<j`ey> no
<rue> onio: It's a program, so just in your terminal
<rue> onio: Though Pry (irb alternative) does have a ri built-in or you can just define a function to shell out to ri in your .irbrc
<onio> ok, ri is another program I run from the shell ?
dv310p3r joined #ruby-lang
porcelina joined #ruby-lang
<rue> Yep
<rue> Just like man(1)
Axsuul joined #ruby-lang
<onio> ok thanks
nofxx joined #ruby-lang
<onio> when you simply use "puts" in the irb console, it's IO#puts, right ?
<rue> At the top level, yes
<Mon_Ouie> No, it's Kernel#puts
<Mon_Ouie> Which calls $stdout.puts
<rue> Er, yes ^
<Mon_Ouie> $stdout is an IO object by default, but it could be something else
ilyam joined #ruby-lang
<drbrain> $stdout.write, not $stdout.puts
<Mon_Ouie> return rb_funcall2(rb_stdout, rb_intern("puts"), argc, argv);
<Mon_Ouie> That does look like it's just calling puts
<rue> onio: So it's Kernel#puts, which is included into Object, which is why you can call it from the top-level object (and any other object which hasn't overridden it)
<rue> My reading's just atrocious of late.
<drbrain> Mon_Ouie: it will call puts if available, but $stdout only needs to respond to #write
<Banistertab> But your heart is still in the right pace
<slyphon> drbrain: oh
<slyphon> drbrain: i wanted to call your attention to something
<drbrain> slyphon: ok...
<slyphon> drbrain: i think this would be a real win for the jruby guys
<slyphon> and i don't think the people on that thread really understood wtf headius was talking about
<rue> drbrain: slyphon already promised to implement it and everything
<slyphon> :)
<slyphon> i might could do that
brianpWins left #ruby-lang
<drbrain> I think I stayed out of that one, can you refresh me?
<slyphon> drbrain: headius was saying that he might have to go off and set up *another* gem service that supports this
<slyphon> ah
* muzone is now playing: AFTA-1 - 4nia (http://www.youtube.com/watch?v=fzBuXumxDX4)
plusk joined #ruby-lang
<drbrain> muzone: uuuugh
<onio> is there a good documentation on how objects are organized in ruby ?
<slyphon> drbrain: well, for pure java gems, you could have a dependncy on maven
<slyphon> so like
<slyphon> for my zookeeper gem
<drbrain> slyphon: I think headius just wanted to have a sep that wasn't on rubygems.org?
<slyphon> i have to create a zookeeper_jar and a log4j_jar gem
<drbrain> sep => dep
<slyphon> it's different from that
<slyphon> which means that i take the official jar and create a slyphon-zookeeper-jar gem
<slyphon> i'm not authoritative, so anyone else is probably going to do the saem thing for *their* project
boodle joined #ruby-lang
<slyphon> rather than that jruby would recognize the 'mvn:' string and take care of pulling it from the official maven repositories
<drbrain> yeah
<slyphon> i think that's a Good Thing
<rue> So JRuby handles the special dependency, and gems only needs to allow such a string as a dep?
gearaholic joined #ruby-lang
zmack joined #ruby-lang
<slyphon> right
<drbrain> I think that's fine
<slyphon> ok, cool i think the issue is that rubygems.org won't parse that dep properly
io_syl joined #ruby-lang
io_syl joined #ruby-lang
<drbrain> yeah
<slyphon> so, if i/headius were to send you a pull req. with that fix, that'd be cool?
<drbrain> and there's already some support in rubygems for allowing fetch from blah
<drbrain> slyphon: I think so
* slyphon nods
<slyphon> cool, ok, that's great
gearaholic joined #ruby-lang
Terri joined #ruby-lang
<drbrain> slyphon: in the pull request message point out that rubygems already has some support for fetching from wherever
* slyphon nods
postmodern joined #ruby-lang
ilyam joined #ruby-lang
<Terri> Hello, all. I'm trying to embed Ruby in a C++ project under MSVC2008. I'm using a locally compiled Ruby 1.9.3. I saw the the embedding docs were woefully out of date and found some code laying around the web that I think may fix that problem, but I'm also having trouble with compiling using the static link library (the linker spits out about 100 lines of hate). I compiled Ruby using...
<Terri> ...MSVC 'nmake', does anyone here have some experience working with this that I could bug for a moment?
a3li joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
gix joined #ruby-lang
<drbrain> Terri: few people do that, you'll probably have some success if you send an email to the ruby-talk mailing list
<drbrain> Terri: especially if it's embedded ruby + MSVC
<Terri> Yes, I'm starting to get that impression, XD
<drbrain> Terri: feel free to stick around though, you may get lucky
<Terri> I'm only using vc because it's a directx app
<Terri> but I'm looking at ruby-forum.com now
<Terri> thank you :)
solars joined #ruby-lang
<drbrain> it mirrors the ruby-talk mailing list
<Terri> yup
<Terri> can i post from here?
<Terri> i mean from ruby-forum.com
<Terri> or do i have to post on the list
<drbrain> if you post to ruby-forum it will show up on the list
<drbrain> and posts to the list show up on the forum
<Terri> cool. ty
<Terri> well, I'm gonna try to fiddle with it a bit more and if this new code doesn't help then I'll try posting on the mailing list. Thanks again drbrain.
<drbrain> Terri: you could paste your output to gist or paste or wherever and link it here, maybe there's an obvious (to us) thing we can help you with
ezkl joined #ruby-lang
deryl joined #ruby-lang
workmad3 joined #ruby-lang
derpcode joined #ruby-lang
<derpcode> can anyone explain to me why (1..10)eql?(1...11) returns false?
<Mon_Ouie> Because 1..10 and 1...11 aren't the same thing
<derpcode> isnt the range 1-10 and 1-10?
<Mon_Ouie> No, it's [1;10] and [1; 11[
<Mon_Ouie> 10.5 is part of the second range
<Mon_Ouie> Not of the first
<derpcode> is 10.1 included to?
<Mon_Ouie> Anything between 1 and 11 except 11
<derpcode> right
<derpcode> thanks Mon_Ouie
<jbwiv_> is there any way to inspect a block's contained logic? i doubt there is, but didn't know if there were any development niceties which would allow it
onio joined #ruby-lang
<Mon_Ouie> You can get the bytecode in a human-readable form
<Mon_Ouie> (well, readable for some humans, at least)
<Mon_Ouie> puts RubyVM::InstructionSequence.disasm proc {|x| x + 3}
<rue> rbx's support is (naturally) better
jensn_ joined #ruby-lang
plusk joined #ruby-lang
<rue> E.g. $ bin/rbx compile -A -S -B -e 'proc {|a| a + 1}' # AST, Sexp and Bytecode
<Banistertab> mon_ouie can you write a translator from bytecode back to ruby
zedUNDginger joined #ruby-lang
<jbwiv_> interesting. ok, thanks gusy
<jbwiv_> guys
<jbwiv_> one other question. Can someone explain what the & is doing in this line "instance_eval &RailsAdmin::Config.authenticate_with"? I'm unfamiliar with the use of & in that way in ruby
<rue> jbwiv_: In a method *call*, it invokes #to_proc on its “argument”
<jbwiv_> rue, ok, so it's essentially the same as col.each {&:size}
<rue> col.each &:size yes
<jbwiv_> woops. yes. ok, so why is the : necessary in the second example?
<rue> :size is a Symbol
<rue> So, what's that mean?
<jbwiv_> ah, i see. ok.
<jbwiv_> i have hazy memories of how that all works. I'll go consult the great oracle Google for details. thanks
<jbwiv_> it's interesting though. RailsAdmin::Config.authenticate_with is already a proc. why would one want to call to_proc on it? perhaps there are cases where it won't be a proc
<rue> It's just calling Symbol#to_proc, and then making a block out of that
<rue> Proc#to_proc just returns self :)
looopy joined #ruby-lang
<rue> So if moo = lambda { 1 + 1 } then foo &moo == foo { 1 + 1 }
<jbwiv_> rue gotcha
<jbwiv_> it's interesting though....if you remove the &, even though it's a proc
<jbwiv_> you get TypeError: can't convert Proc into String
<jbwiv_> whereas instance_eval &RailsAdmin::Config.authenticate_with works
<rue> Right, because without & expanding it, it's the same as instance_eval(Railsblahblah)
<jbwiv_> rue: ok, I follow you
<jbwiv_> so if you don't use &, it's put in the main param to instance_eval which expects a string. but if you use &, because it's a proc, it's put into the block variable the method accepts
<rue> If you don't use &, it's just a parameter
<jbwiv_> it's still odd to me, though, that & is required. it's already a proc...shouldn't the runtime be smart enough to realize it's a proc and place it in the appropriate param?
<rue> You may not want to do that
<rue> As in, it could be that you don't want that behaviour
<rue> Maybe you do want to pass it in as a param
<rue> Plus it's a visual cue that it is indeed a block
<jbwiv_> rue: I see. gotcha
<jbwiv_> thanks
gd__ joined #ruby-lang
<gd__> hi all
<gd__> hope someone can help me: how can i break a .reduce iteration with a return value?
headius joined #ruby-lang
<gd__> so i can write the following: ret_val = foo.reduce(false).reduce { |a,b| ...some..code..; break if a == true }
<gd__> and have the true in my ret_val
<gd__> lol
<gd__> i have it
<edwardsharp> gd__: use when?
<gd__> break with_value
<edwardsharp> case 'pump'
<edwardsharp> when 'pump', 'throbb'
<edwardsharp> puts "pump or throbb"
<edwardsharp> end
<gd__> edard, how can i stop iteration with case?
<edwardsharp> the when statement
<gd__> in the .reduce iteration?
<edwardsharp> yup
andrewhl joined #ruby-lang
<gd__> wow i read it up thnx
<gd__> do you have a one liner example
<gd__> i don't get it
<gd__> my solution: ret_val = foo.reduce(false).reduce { |a,b| ...some..code..; break a if a == true }
<edwardsharp> ok, um
publicvoid joined #ruby-lang
Spooner joined #ruby-lang
<edwardsharp> ret_val = foo.reduce { |a| Obj.method(a) unless Obj.param.nil? }
srbaker joined #ruby-lang
<edwardsharp> .false?
<edwardsharp> depends on the object, i suppose.
<gd__> it seemd you completly did not understand my question
cjs226 joined #ruby-lang
ilyam_ joined #ruby-lang
<gd__> maybe my fault
<gd__> sry
solars joined #ruby-lang
<rue> gd__: You can use break, yes
<edwardsharp> try? &&?
<steveklabnik> that's rails only
<steveklabnik> and it's basically just _send_, look at the source. ;)
hagabaka joined #ruby-lang
<rue> gd__: But then you probably shouldn't be using #reduce (or #inject as you should probably call it)
ivanoats joined #ruby-lang
<steveklabnik> yeah
brianpWins joined #ruby-lang
<steveklabnik> unless it was being lazily evaluated
<steveklabnik> then you might be okay.
zedUNDginger joined #ruby-lang
<gd__> rue: nn sideeffects
<gd__> so i stay with reduce, or you teach me better by example :)
<gd__> and i want to call it reduce, not inject as inject is missleading
<gd__> reduce_left ftw
<steveklabnik> heh
<rue> Well, I'll wager 85% of Ruby programmers will have to check the documentation to figure out what you're trying to do
onio joined #ruby-lang
<rue> For better or worse, it's #inject
<steveklabnik> you either go with haskell, or smalltalk.
<steveklabnik> collect/inject or map/reduce
<steveklabnik> most rubyists pick smalltalk
<rue> gd__: Without an actual use case I can't say if there's a better option, but breaking early out of a reduce, as you say, is smelly
<rue> Which is to say it might be necessary, but warrants consideration
<gd__> blabla :)
<onio> I'm a noob, is this correct :
<onio> class Bear
<onio> @@bears = {
<onio> "winnie" => Bear.new("Winnie"),
<onio> "balou" => Bear.new("Balou")
<onio> }
<onio> end
<onio> ??
<gd__> pastebin!
<rue> onio: 1. Use gist or pastie (/topic) and 2. sure, that works if that's what you want to do
perryh_ joined #ruby-lang
<onio> sorry
<rue> You could use a constant, perhaps, or a method, a class ivar instead of a class var…
jensn joined #ruby-lang
<onio> ok but is it correct to put some objects references as second members of hashes ?
<rue> Yes, for a Hash you can use any object as a key and as a value
<rue> (For keys, the object needs to respond to #hash and #eql?)
<onio> ok it means I have to write a hash method to calc the key , right ?
<rue> onio: ri Object#hash :)
boodle joined #ruby-lang
slyphon joined #ruby-lang
RickHull left #ruby-lang
Banistertab` joined #ruby-lang
slyphon_ joined #ruby-lang
<onio> ok for ri
Rakko joined #ruby-lang
<onio> I'm sorry I really don't know anything to irc, I guess pastebin, gist or pastie are tools to paste source code, is that correct ?
<steveklabnik> yes
<injekt> :)
<injekt> gist or pastie
<injekt> pastebin makes me gag
looopy joined #ruby-lang
<Rakko> hi
mksm joined #ruby-lang
<onio> to use a static method, i write it "def self.method(arg)", then I call Class.method right ?
<steveklabnik> ruby doesnt have static methods
<steveklabnik> it does have class methods though
<steveklabnik> which is what that is
<steveklabnik> and that is how you call them.
<steveklabnik> and it wouldnt be Class.method
<steveklabnik> it'd be YourClass.method
<steveklabnik> and you could also define it as def YourClass.method(arg)
<steveklabnik> ... though that's kinda stupid.
tomzx joined #ruby-lang
<steveklabnik> (because Class is already a class ;) )
<onio> ok I read that you're right my example is stupid
<steveklabnik> it's not, i was just picking knits. sorry.
<steveklabnik> it's funny, because 'method' is actually a method on Object, not Class...
<steveklabnik> heh.
<steveklabnik> whateves, i'm rambling. you have the correct idea.
<onio> I come from c++, it's hard to switch between ruby which is a very evolved programming language, and c++ which is powerful at runtime but hard to write
<steveklabnik> but they are class methods not static methods
<steveklabnik> absolutely.
<onio> ok
<steveklabnik> C++ damages your brain. ;)
zedUNDginger joined #ruby-lang
<onio> you're right but assembly is worse
<Asher> or php
<steveklabnik> naw, that teaches you stuff.
porcelina joined #ruby-lang
Guest2452 joined #ruby-lang
<onio> when I am on a method definition is self the reference of the current object or the reference of the current class ?
<andrewvos> php teaches you what? To type faster?
<Asher> i think he meant asm teaches you
<andrewvos> ahh
<Asher> giving him benefit of the doubt ;)
<andrewvos> :)