Topic for #ruby-lang is now Ruby 1.9.3p0: http://ruby-lang.org | Paste >3 Lines of Text on http://pastie.org
<drbrain> tjgillies: so for this type of thing I'd think that Panda and Grizzly would maybe include FourLegged ?
<tjgillies> drbrain: thnx
<tjgillies> so i take it trying to make include conditional is a bad thing
<drbrain> it's frowned upon
<tjgillies> ok
<drbrain> there are places where it's a good idea but IMO this isn't one of them
<drbrain> also, Sniper and BowAndArrow could include Ranged
<tjgillies> so im doing class Fighter < Person; include Melee; end;
<drbrain> … although subclassing from a Ranged might be better there
<drbrain> that sounds nice
<drbrain> I think inclusion is best used when you're either adding behavior like Enumerable or need to express multiple-inheritance
<drbrain> like your Fighter above
<tjgillies> class Mage < Person; include FireSchool; include EarthSchool; end;
<drbrain> yes
<tjgillies> drbrain: thnx
igotnolegs joined #ruby-lang
<tjgillies> that worked out nicely
Axsuul joined #ruby-lang
<drbrain> that seems nice
<petercooper> why method&call instead of send?
looopy joined #ruby-lang
<petercooper> There must be a reason, I just haven't turned my head on full today :-)
<drbrain> petercooper I think send is better too, I forgot about it
fayimora joined #ruby-lang
korch left #ruby-lang
heppy_ joined #ruby-lang
<tjgillies> petercooper: what would syntax for that be?
<petercooper> send spell_name
<petercooper> as the entirety of that cast method
<tjgillies> petercooper: thnx
wallerdev joined #ruby-lang
takaokouji joined #ruby-lang
nofxx joined #ruby-lang
banister_ joined #ruby-lang
Cerales joined #ruby-lang
<Cerales> I just built my own gem for the first time, and installed it with gem install from the local directory. when I try to require it, though - with the name I specified in the gem spec - I get "no such file to load". any ideas, anyone?
<Cerales> oh, it was a problem with my require_path. never mind!
srbaker joined #ruby-lang
replore_ joined #ruby-lang
livinded joined #ruby-lang
banisterfiend joined #ruby-lang
wyhaines joined #ruby-lang
yfeldblum joined #ruby-lang
fenicks left #ruby-lang
resetexistence joined #ruby-lang
wyhaines_ joined #ruby-lang
jmontross joined #ruby-lang
<zenspider> sexp_processor 3.0.9 released
<zenspider> Cerales: you wouldn't have that problem if you didn't hand roll your own gemspec
<zenspider> Hoe is your friend (tm)
looopy_ joined #ruby-lang
vesan joined #ruby-lang
neoesque joined #ruby-lang
mbriggs joined #ruby-lang
lianj joined #ruby-lang
chris2 joined #ruby-lang
artOfWar joined #ruby-lang
cjs226 joined #ruby-lang
srbaker joined #ruby-lang
<zenspider> minitest 2.9.0 released
<zenspider> rawr
jmontross joined #ruby-lang
<erikh> ha, I just installed 2.8.3 or w/e hte last release was about 30 minutes ago
<erikh> oh fwiw there's something up with hoe's rake newb on 1.8.7. haven't sorted it yet
<erikh> I'm pretty sure it and 'rake test' are running two different battery commands
<erikh> it's that test/unit problem we were seeing ages ago where it gets confused with minitest plugin installed
<erikh> anyhow, I'll file if I run across it again and find anything I can pinpoint.
ryanf joined #ruby-lang
andrewhl joined #ruby-lang
slyphon joined #ruby-lang
amerine joined #ruby-lang
Kero joined #ruby-lang
Defusal joined #ruby-lang
Defusal joined #ruby-lang
jbwiv__ joined #ruby-lang
<josh9> in 1.9.3, bcrypt is not part of the standard-library?
jmontross joined #ruby-lang
<rue> N-uh
slyphon joined #ruby-lang
slackstation joined #ruby-lang
lightcap joined #ruby-lang
looopy joined #ruby-lang
looopy_ joined #ruby-lang
Nisstyre joined #ruby-lang
looopy joined #ruby-lang
robbyoconnor joined #ruby-lang
krz joined #ruby-lang
wyhaines joined #ruby-lang
tallship joined #ruby-lang
io_syl joined #ruby-lang
io_syl joined #ruby-lang
r0bby joined #ruby-lang
looopy_ joined #ruby-lang
headius joined #ruby-lang
artOfWar joined #ruby-lang
dr0id joined #ruby-lang
twittard joined #ruby-lang
<drbrain> nope
<steveklabnik> tenderlove wants to add it for 2.0
x0F__ joined #ruby-lang
gfarfl joined #ruby-lang
phlipper joined #ruby-lang
rohit joined #ruby-lang
Nisstyre joined #ruby-lang
Ruthenium joined #ruby-lang
spuk joined #ruby-lang
r0bby joined #ruby-lang
<rue> 2.0? I think you mean 2.awesome!
<Asher> few people are aware that awesome is a number
<lianj> textmate-2.nevar
<livinded> lianj: you just stole my joke~
<livinded> !
<petercooper> it's the square root of -i
<lianj> livinded: hehe
<livinded> I can't wait for textmate 2 alpha to not be delivered in time for christmas and hopefully everyone realizes it's vaporware and moves on to vim
<drbrain> gah, no
<drbrain> at least, don't bring any of that crappy hand-holding bullshit with you
<drbrain> learn you a command mode
<livinded> and some text-objects!
<drbrain> YES!
<petercooper> would you like an operating system with that?
<livinded> petercooper: I don't need one, vim runs on everything!
<dr0id> I want some ruby
<drbrain> petercooper: I learned that emacs is all about meta-x-fuck-fuck-fuck
<drbrain> but I learned from zenspider so I may have been stunted
<livinded> the best part about emacs is meta-x spook
<livinded> I think it's meta-x
<livinded> maybe it was meta-c
<drbrain> livinded: it's just as confusing as the difference between insert and command mode
<livinded> drbrain: not saying that it's not. I just personally think vim's commands are easier to remember than emacs'
<livinded> at least the default mappings
<rue> Dunno if they're easier to remember…
<rue> Easier to type, certainly
<drbrain> emacs doesn't have a learning cliff, that's for sure
<livinded> I wish emacs used scheme
<rue> When I broke my wrist, the doctor gave me the rundown: I can still ride a bike, but I'll never be able to operate emacs
<livinded> think I'd be more temped to use it
ahf joined #ruby-lang
<rue> What about schemacs?
<livinded> rue: that sounds pretty cool
banisterfiend joined #ruby-lang
JosephRuby joined #ruby-lang
Nisstyre joined #ruby-lang
<andrewhl> is anyone here familiar with nokogiri
<Asher> what's your question
<andrewhl> i'm trying to scan an html document for a string, and then return if it's found
<andrewhl> but it seems to be returning for every document I'm scanning, regardless of whether or not the string is there
<andrewhl> here's my pastie:
<Asher> it returnsa NodeSet right?
<Asher> i think you just have to check if the return is empty
<andrewhl> I want it to break out of the function its in if it finds the string
<rue> It does, yes
<andrewhl> is return the correct way to do that?
<Asher> no you want to check if the nodeset is empty then return if it is not empty
<andrewhl> oh
<andrewhl> how would I write that...?
<bnagy> you probably want select
<bnagy> kgs_names.select {|name| #get page, check for string}
<andrewhl> hmm
<rue> Does the :contains selector work?
<andrewhl> kgs_name is a single string though
<bnagy> I just assumed you had more than one name in an array somewhere
gokulnath joined #ruby-lang
<rue> Does indeed
<andrewhl> the array is outside the function that requires nokogiri
<rue> So you can do doc.css "a:contains('0 games')"
<rue> Er, h2
<andrewhl> it passes each name individually as an argument to the parser
<andrewhl> so if doc.css ... return end?
<andrewhl> that simple?
<twittard> Any design pattern gurus here?
<Asher> twittard what's your question
<rue> andrewhl: If return is what you want
<andrewhl> I want to break out of the current function if it finds the string
<bnagy> which I doubt
<twittard> Asher: Actually, I think I answered it. Basically, I'm trying to decide which Design Pattern the use of Callbacks best falls under.
QaDeS joined #ruby-lang
<twittard> I had a hunch the "Visitor" was probably the best fit
<twittard> Seems so?
<bnagy> hahaahhaha
<rue> No, visitor is slightly different
<twittard> Maybe observer. But this isn't pooling up callbacks
<rue> More Strategy or Command
<twittard> rue: Actually, I think you're right. Stragegy sounds right.
WhiteHorse joined #ruby-lang
<zenspider> PickRandomBuzzword
<twittard> Design Patterns aren't really buzzwords.
<twittard> (if that was lobbed at me)
<rue> zenspider: That one didn't make the cut in the 1st edition
<banisterfiend> what's up zenspider
<zenspider> They Are If They're Captitalized
<bnagy> omg I am going to die of laughter
<zenspider> banisterfiend: I heard you were banned :P
<rue> He's learned his lesson, haven't you?
<banisterfiend> zenspider: Yeah, i'm on my phone now and i dont think he got to this ip yet
<zenspider> hah
<banisterfiend> i'm not purposely evading a ban, this chan is just on auto-join ;)
<banisterfiend> rue: Yeah
<zenspider> seems you have a periodic tendency to Make Really Poor Choices
<zenspider> that's a pattern, right?
<rue> :D
<bnagy> which annoying / amusing banisterfiend habit did you get banned for?
<banisterfiend> yeah i get drunk and post inappropriate links
<zenspider> pasting porn
<rue> That should be a pattern… let's email Gamma
<lianj> haha
<banisterfiend> well i think teh emphasis of that picture was more comedic content than pornography but i guess it still met the definition of porn
<banisterfiend> hehe
<banisterfiend> though, there was no privates or even breasts displayed in that pic
<rue> I wonder if my GoF is still at the parentages. I haven't seen it since…2000 or something.
<bnagy> . o O (so tempted to ask 'which link' and get him banned again...)
<banisterfiend> just a naked fat guy eating tinned corn and resting them on the back of naked girl
<banisterfiend> but all teh crucial areas were obscured
<ryanf> resting... the corns?
<banisterfiend> resting the cans
<erikh> cr0n
<rue> I think the Wikipedia page for GoF is the worst one there is
<rue> It's almost as obtuse as the book itselg
<rue> ff
<twittard> This wikipedia editor with "18,000 edits" looks like she should be in school and not defacing her homework assignments.
<twittard> Not giving them my money.
<WhiteHorse> whats the best way to grasp ruby coming from languages like java and php?
<WhiteHorse> any tutorial sugestion?
<twittard> WhiteHorse: Have you used tryruby.com?
<twittard> sorry, .org
<twittard> tryruby.org
<rue> WhiteHorse: Relatively experienced programmer?
<bnagy> wait I thought he said java / php ;)
<erikh> uuuuuuuugh
<zenspider> WhiteHorse: write lots of ruby code
<erikh> why do I feel I need a set of liberty spikes and a jacket with safety pins all over it when I look in here
<rue> bnagy: You get to write LOTS of code in Java, and plenty of debug experience with PHP
<bnagy> what are liberty spikes?
<rue> erikh: That doesn't sound like hipster wardrobe at all
<bnagy> rue: which leaves 1% of the time for programming! Yay!
towski joined #ruby-lang
<WhiteHorse> havent tried that yet
srbaker joined #ruby-lang
<erikh> sheena is
<WhiteHorse> well im not experienced but i understand a lot of object oriented concepts and stuff
<ryanf> wait yeah uh
<ryanf> is ruby punk now?
<ryanf> if so, I am clearly working with the wrong people
macmartine joined #ruby-lang
<WhiteHorse> lol ryanf
<twittard> WhiteHorse: Depends on what you're looking to do. You can always do the Rails / Sinatra tutorials, if you want to do web development. This will give you a feel for Ruby while "doing something" in the beginning.
<bnagy> WhiteHorse: what do you want to do?
<WhiteHorse> yes im following the rails 3 tutorial from michael hartl
<WhiteHorse> but i feel like.. id like to learn ruby lang first
<twittard> WhiteHorse: Well, you definitely have the right mentality :).
<ryanf> I think WhiteHorse just said this room's titular line
<erikh> haha is this a too short parody?
<ryanf> he came to learn... ruby lang
<rue> WhiteHorse: “Ruby for Rails” is a good book
<ryanf> I'm just so tired of all these ruby langs
<bnagy> puzzlenode problems are pretty cool, but they're going to be very hard if you're not a programmer
<erikh> hah this is great
<zenspider> I'm unfamiliar with puzzlenode
<bnagy> zenspider: http://puzzlenode.com/
<twittard> Seems like a Ruby TL;DR is worth putting together.
<rue> erikh: Here's a counterargument if you've not seen it yet: https://www.youtube.com/watch?v=Vn29DvMITu4
<erikh> I think it's called the quickref
<zenspider> corundum: quickref?
<erikh> some dork in here wrote it, can't remember his name
<erikh> :P
<zenspider> I heard he's a jerk
<WhiteHorse> well if ruby were similar to C in syntax i wouldnt care. but it is really different from C-like langs so... i think that i have to put some time learning it first before the actual framework
<rue> Zed Shaw maybe?
<erikh> nah, DHH
<zenspider> yeah him
<erikh> speaking of which
<erikh> maybe you guys can help me with negative zero-width assertions
<bnagy> yes, don't use them
<erikh> because I had the dumb earlier today
<erikh> yes, I generally do not
<erikh> I was trying to detect an escape of a %, e.g. \%
<erikh> and ignore it
<twittard> WhiteHorse: There's always: http://ruby.learncodethehardway.org/book/
<erikh> so I had something like (?!\\)%
<twittard> But I don't really care for the layout of the book
<erikh> which obviously did not work
<bnagy> I hate the 'hard way' solutions, they look like ported python
<twittard> It's below your level and doesn't get into the "magic" of ruby.
<twittard> Exactly
<twittard> Problem is, there are books about Ruby for absolute beginners.
tomzx joined #ruby-lang
<twittard> WhiteHorse: To some extent, it might be worth it to just do the Rails tutorial and swallow some of the magic.
<rue> erikh: Right, that's the wrong way around?
<twittard> WhiteHorse: Or maybe, I can help you through the magic as you come across it. It might help me, too. I'm doing a presentation to some Java developers tomorrow.
<bnagy> I want 'swallow some of the magic' on a tshirt now
<twittard> And I've forgotten all the things that surprised me.
<erikh> is it %(?!\\)
<erikh> sorry, mysql server just went tits up, be back in a bit
<twittard> about Ruby, that is.
<ryanf> erikh: don't you want (?<!\\)% or something like that?
<erikh> 1.8
<erikh> anyhow really gtg
<ryanf> ahh
<ryanf> man I don't know why people are always so down on zero-width assertions
<ryanf> they're fun
<ryanf> :)
<WhiteHorse> i really like http://ruby.learncodethehardway.org/book/ it seems concise and straight to the point
replore joined #ruby-lang
<oddmunds> WhiteHorse: i'm just quickly looking at that, but am i wrong in that it's not very ruby idiomatic?
<twittard> WhiteHorse: The problem with the guide is, while it will port some concepts over from other languages, it doesn't give you a "ruby" way. So you're barely learning ruby syntax.
<oddmunds> and more or less directly translated from python?
<oddmunds> haha
<twittard> err, you're only learning ruby syntax.
<oddmunds> twittard: i think we noticed the same thing
<twittard> You're not, for example, learning about blocks.
<twittard> Or Mixins
<twittard> WhiteHorse: In ruby, you don't write "for" loops. Ever. They look stupid after using Ruby.
<WhiteHorse> lol
<WhiteHorse> how u do for loops then?
<oddmunds> each and blocks
<twittard> ["foo", "bar"].each { |item| puts item}
<oddmunds> actually that's not the same as a for-loop
<oddmunds> it's better
<twittard> Right
<WhiteHorse> oh ive seen those in the tutorial :S
<twittard> ["foo", "bar"].each_with_index { |item, index| "#{item} is at index #{index}" }
<lianj> each.with_index
<twittard> Or each_with_index
Pip joined #ruby-lang
<twittard> WhiteHorse: 5.times { puts "Hello!" }
<twittard> Without blocks, Ruby is just Python with a less hideous syntax.
<lianj> twittard: sure bit .with_index suggests that it works with map etc too
<lianj> *but
<twittard> lianj: I do each_with_index.map all the time
<twittard> Or are you saying map.with_index ?
<lianj> yes, map.with_index
[dmp] joined #ruby-lang
[dmp] joined #ruby-lang
<twittard> Same effect. I imagine the overhead to both are identical
* twittard ponders a benchmark
aef joined #ruby-lang
<WhiteHorse> so u can call an each method in any object that behaves like an array/vector?
corecode joined #ruby-lang
darix joined #ruby-lang
darix joined #ruby-lang
<oddmunds> every object that "includes" Enumerable
<twittard> WhiteHorse: Any class that includes Enumerable and implements an #each method
valeri_ufo joined #ruby-lang
rane_ joined #ruby-lang
<twittard> But you don't actually have to include Enumerable
<oddmunds> twittard: i like that we're on the same track :)
<twittard> WhiteHorse: You can code it yourself. It's just more painful.
<twittard> oddmunds: :D
jwollert joined #ruby-lang
<lianj> twittard: each_with_index.map is different from map.with_index
<twittard> WhiteHorse: Well, not painful. Just, you have to write the details yourself. It's pretty easy, tbh.
tekin joined #ruby-lang
LanceHaig joined #ruby-lang
jasiek joined #ruby-lang
comboy joined #ruby-lang
vereteran joined #ruby-lang
<twittard> lianj: Is it? How? (Looking at the API docs)
_rane joined #ruby-lang
<lianj> you will find out ;)
soahccc joined #ruby-lang
denysonique joined #ruby-lang
denysonique joined #ruby-lang
a3li joined #ruby-lang
takaokouji joined #ruby-lang
timbleck joined #ruby-lang
<twittard> lianj: I don't see anything describing how it's different :(. Seems like identical behavior so far.
<twittard> Oh fine, I'll open up IRB
<WhiteHorse> by include you mean inheritance? or just a java like "import"
<twittard> Same behavior
<twittard> WhiteHorse: Ruby is Single Inheritance only.
mccraig joined #ruby-lang
meise joined #ruby-lang
<lianj> twittard: nope
<twittard> WhiteHorse: Mixins let you get around that. They're akin to interfaces, but not really. They let you, in a sense, do the multiple inheritance thing but more cleanly.
<WhiteHorse> twittard: PRY looks better than IRB ;)
<twittard> WhiteHorse: If you have several different pieces of functionality, you can include or extend them.
<twittard> WhiteHorse: It is :)
<twittard> And make them shareable, etc.
beawesomeinstead joined #ruby-lang
rohit left #ruby-lang
<twittard> WhiteHorse: Let me hack up an example
Weems joined #ruby-lang
whoops joined #ruby-lang
<twittard> WhiteHorse: https://gist.github.com/1446231
<jammi> hi, any other ideas about a ruby timezone library than tzinfo?
<WhiteHorse> whats a module? like a java package?
<erikh> well that was fun
<WhiteHorse> lol
<twittard> WhiteHorse: Not really. The common comparison is an Interface.
<twittard> WhiteHorse: Except you're implementing the details of it.
<twittard> WhiteHorse: I added another example. A lot of "magic" in ruby comes from callbacks: https://gist.github.com/1446231
<twittard> so, included / extended / inherited ... all can get called (if defined) when those things happen. So you can inject functionality behind the scenes.
mrchrisadams joined #ruby-lang
<twittard> WhiteHorse: Not sure what the best Java analogy would be. A module is just a bunch of functionality that you want to share between classes (generally)
<drbrain> yes
kitallisii joined #ruby-lang
simon_weber joined #ruby-lang
abuiles joined #ruby-lang
<WhiteHorse> ok.. so you can choose to extend or include that bundle of functionality?
<twittard> WhiteHorse: Without the "instance_exec", "FooBar" would have never inherited those methods from the modules. It's pretty nice, imo, and prevents things from becoming a ball of mud.
<twittard> WhiteHorse: Right. Generally, "include" gives the functionality to instances of the class... While extend gives it to the class itself.
<headius> zenspider: another issue with excludes implemented like this...it still runs setup
<headius> if setup has an issue, it still fails (or in this case, hangs)
<headius> I'll poke at it
vereteran joined #ruby-lang
<headius> hmm, does setup and teardown run before and after each test method or before and after the whole thing?
<drbrain> each test method
<drbrain> roughly, test_case = new; test_case.setup, test_case.test_the_thing; test_case.teardown
cesario joined #ruby-lang
<headius> I have a hack that works... exclude :setup
<headius> but that kills it for all tests
<headius> I think I need to patch this... don't do any of setup or teardown if it's excluded
<drbrain> yeah
<WhiteHorse> twittard: so if you extend Bar you can't utilize its methods in the instances?
<WhiteHorse> thats weird
<twittard> WhiteHorse: Yeah
<twittard> WhiteHorse: It's interesting.
<twittard> in quotes.
<WhiteHorse> so they are pretty much like java static methods
<twittard> Ok, there you go! Noting that reference
<drbrain> WhiteHorse: extend works on instances
<drbrain> include works on classes
michael_mbp joined #ruby-lang
<WhiteHorse> Baz.foo would throw an exception too?
savage- joined #ruby-lang
<twittard> WhiteHorse: Right.
<drbrain> WhiteHorse: you can extend on an instance and add those methods just to the instance
jredville joined #ruby-lang
<twittard> WhiteHorse: Yes, what drbrain said.
<savage-> can you guys help test something? http://www.spreecast.com/events/checking-in--5
<twittard> Hard to give a concise example and not portray it as law.
yxhuvud joined #ruby-lang
<drbrain> o = Object.new; def o.each; yield 1; yield 2; yield 3 end; o.extend Enumerable; p o.map { |x| x * 2 }
cldwalker joined #ruby-lang
<drbrain> class Foo; extend M; end works on the object Foo
<headius> drbrain: I need a way to get minitest not to print anything for skips, since I'll have so many
<headius> it's not interesting to see them
dnyy joined #ruby-lang
<drbrain> headius: S vs . or in the full output?
<headius> the full output
<headius> the S vs . is fine
<drbrain> that's automatic
twittard joined #ruby-lang
<headius> I may add a patch for ENV['QUIET_SKIPS'] or something
<headius> I'll have hundreds
<twittard> and back
<drbrain> hrm
<drbrain> what's the flag
toretore joined #ruby-lang
<headius> flag?
<drbrain> headius: Skip: output is suppressed by default
<drbrain> in 2.9
setmeaway joined #ruby-lang
<headius> hmmm
<drbrain> you must add -v to see Skipped: output
Tybalt joined #ruby-lang
Pip_ joined #ruby-lang
<headius> oh, righto
<headius> I have that because I'm building up my excludes
<headius> so it won't be there later...no problemo
r0bby joined #ruby-lang
<headius> this is going to be sexy
SirThomasMore joined #ruby-lang
SirThomasMore joined #ruby-lang
Tyblat joined #ruby-lang
<WhiteHorse> twittard: thank u for the example by the way
<twittard> WhiteHorse: No problem :). Happy to help. Ask questions as you come up with them.
<WhiteHorse> so to do a "b.each" I would need to include Enumerable inside the class?
<drbrain> WhiteHorse: yes
<WhiteHorse> is there a way to redefine my class in PRY without restarting and rewriting all the stuf again? :D
<WhiteHorse> lol
<drbrain> WhiteHorse: classes are open
<drbrain> so unless you want to un-include a module, just reopen it and add stuff
<drbrain> class MyClass; include Enumerable; end
<WhiteHorse> I can do that in my normal ruby files too?
banisterfiend joined #ruby-lang
<drbrain> yes
<WhiteHorse> wow that really is interesting
<WhiteHorse> ruby has a truly dynamic nature indeed
akahn joined #ruby-lang
sinuc joined #ruby-lang
sinuc joined #ruby-lang
zerokarmaleft joined #ruby-lang
<twittard> WhiteHorse: Hence the phrase, "Monkey Patching"
<twittard> WhiteHorse: But it's used all the time. Sometimes foolishly, sometimes elegantly. Periodically, drunkenly.
mytrile joined #ruby-lang
Axsuul joined #ruby-lang
agib joined #ruby-lang
mytrile joined #ruby-lang
ryanf joined #ruby-lang
sopheak joined #ruby-lang
<sopheak> hi all, can you guys tell me about how can i install rails in my pc?
<sopheak> i'm using Ruby 1.9.3
<twittard> sopheak: By PC, do you mean windows?
<sopheak> yes
<havenn> sopheak: http://railsinstaller.org/
<twittard> Yes, that.
<sopheak> and through this installation, will i get the webservice and MySQL?
<WhiteHorse> I just stumbled upon this ruby video tutorial: http://vimeo.com/24093428 looks really nice
<WhiteHorse> I think its by the same guy who created pry
<Asher> nah someone else
frangiz joined #ruby-lang
<WhiteHorse> well that guy joshua has an *excelent* video tutorial on pry.. probably the best out there
<Asher> ya
<rue> sopheak: See what the site tells you it installs; it may not provide all dependencies. Also, there's a #rubyonrails
Pip joined #ruby-lang
Pip joined #ruby-lang
<sopheak> rue, thank you :)
JohnBat26 joined #ruby-lang
cshrn joined #ruby-lang
srbaker joined #ruby-lang
r0bby joined #ruby-lang
dr0id joined #ruby-lang
<shevy> MAKE LOVE, NOT CODE
<rue> Make sleep, not wakey
jmontross joined #ruby-lang
cshrn joined #ruby-lang
<josh9> i have @@users. how to write attr_accessor for it?
<rue> Accessors are just methods
<ryanf> yeah you pretty much ahve to just write a getter and setter
<ryanf> or write a helper method to generate them like cattr_accessor from rails
srbaker joined #ruby-lang
dc5ala joined #ruby-lang
<shevy> hmm
<josh9> ryanf: got it. i'll keep my setter.
tomzx joined #ruby-lang
heppy joined #ruby-lang
masterkorp joined #ruby-lang
<rue> josh9: Or just not use @@vars if you don't specifically need shared-hierarchy
<josh9> rue: it's a db related object that i pass to my User class (domain model) so i think it's ok to have a shared var.
jmontross joined #ruby-lang
<headius> zenspider, drbrain: 2259 tests, 656626 assertions, 0 failures, 0 errors, 833 skips
<headius> running test/ruby/test_*.rb in JRuby
takaokouji joined #ruby-lang
<shevy> well done student!
* shevy gives headius an A-grade
<headius> yay
<FastJack> what? no AAA rating? ;)
<shevy> naaah
<shevy> triple A isn't worth much these days
<shevy> hmm
<shevy> it sounds very important though
<shevy> "Triple A"
solars joined #ruby-lang
<rippa> Triple A is a type of battery
<shevy> don't you imagine a big Limousine in your head when you hear Triple A?
<rippa> also Double S sounds nicer than SS
<shevy> a battery?
<shevy> oh odd
<shevy> I know these, didn't hear AAA battery before though
roadkith joined #ruby-lang
saLOUt joined #ruby-lang
srbaker joined #ruby-lang
hhatch joined #ruby-lang
<shevy> hmmm
workmad3 joined #ruby-lang
jensn joined #ruby-lang
Natch| joined #ruby-lang
heftig joined #ruby-lang
AlHafoudh joined #ruby-lang
Neil joined #ruby-lang
saLOUt joined #ruby-lang
sopheak joined #ruby-lang
thrcka joined #ruby-lang
yorickpeterse joined #ruby-lang
looopy joined #ruby-lang
dnjaramba joined #ruby-lang
heppy joined #ruby-lang
gnufied joined #ruby-lang
molgrew joined #ruby-lang
Guest92254 joined #ruby-lang
hhatch joined #ruby-lang
hhatch joined #ruby-lang
cyri_ joined #ruby-lang
uniqanomaly_ joined #ruby-lang
zmack joined #ruby-lang
banisterfiend joined #ruby-lang
basicxman joined #ruby-lang
looopy_ joined #ruby-lang
anjen joined #ruby-lang
Rich_Morin joined #ruby-lang
<Rich_Morin> I'm confused. I have this line of code: pct_hash = @md.hash[@comp_key][@item_key][pct_key] rescue {}
<Rich_Morin> If the hash lookup fails, shouldn't pct_hash get set to {} ?
<bnagy> a failed lookup doesn't raise an exception
<bnagy> it just returns nil
<manveru> you want @md.hash.fetch(@comp_key, {}).fetch(@item_key, {}).fetch(pct_key, {})
woollyams joined #ruby-lang
<Tasser> manveru, actually, that loooks more complicated than the above one
<Tasser> hmm, fetch + rescuing KeyError might be better
<bnagy> except it works :)
<bnagy> I would just replace rescue with || personally
<rue> Ew variable names
adambeynon joined #ruby-lang
<bnagy> or create the hash with a default object in the first place
<rue> That'd be sensible
<rue> ri Hash.new
Pupeno joined #ruby-lang
<bnagy> but don't forget to use the block form or you won't get what you expect
<bnagy> h=Hash.new {|h,k| h[k]={}}
<rue> Why can't we just make people RTFM?
<Rich_Morin> I know about that, but this way seemed to be working (and a lot simpler) until I tried to do a rescue {} instead of a rescue nil.
<bnagy> Rich_Morin: as I said, it's not raising, it's just returning nil from the lookup, which is what Hash does by default
<bnagy> you would only rescue there if you were trying to cope with a 'sub' hash not being there
<Rich_Morin> Well, if the hash returns a nil, the next level lookup will fail (as shown in the pastie)
<bnagy> that's right
<bnagy> but obviously that's not happening
<Rich_Morin> so, indeed, I can get an exception (but may not if only the last leookup fails)
<bnagy> s/may/will/
neoesque joined #ruby-lang
<Rich_Morin> right - so, I think I'll use (a[:q][:w] rescue nil) || {}
roha joined #ruby-lang
<bnagy> yes, that is definitely the ugly and hacky way to do it
<bnagy> go forth and be a prel programmer in ruby
<Rich_Morin> go forth and read "Exceptional Ruby"
<rue> Rich_Morin: Why in the fuck would you use that?
<Tasser> bnagy, the recall of {} is high, but the precision sucks.
<manveru> why does nobody like fetch :P
<bnagy> I do
<bnagy> I was just about to say so
<bnagy> although I like having a default object better
<Rich_Morin> rue: Well, one reason is that I have quite a bit of code that I'd have to rework to use Hash.new. Another is that Hash.new is a bit ugly. Finally, what the @#$%%^ is wrong with using Ruby's exception mechanism?
<rane_> not a huge fan of using exceptions like that
<manveru> yeah, but 3 nested ones?
<bnagy> makes it clearer when you're reading the code
<manveru> Rich_Morin: exceptions are slow
<rippa> exceptions are for exceptional situations
<rippa> when you have a nerror
<rippa> *an error
<manveru> that too :)
benanne joined #ruby-lang
<Rich_Morin> speed is not an issue in this case. and, indeed, not finding the element I'm looking for is an exceptional situation That said, I'll think about it...
<rue> If that's the exceptional situation, it'd be best for your code to reflect it
<rane_> if it was an exceptional situation you would log it
<rue> I.e., bail if :q doesn't exist
LanceHaig joined #ruby-lang
gnufied joined #ruby-lang
Pip joined #ruby-lang
<manveru> man, this thing can't run stuff for long :(
<rue> The rescue version is also doing much less work.
<manveru> yeah
<manveru> doesn't help it much
dave_miles joined #ruby-lang
<Rich_Morin> The rescue version you have will return nil sometimes
<manveru> http://pastie.org/2985198 same thing with 1MM iterations
geoffw8_ joined #ruby-lang
<manveru> i'm assuming the default-proc one becomes quite GC heavy
<manveru> the rescue one creates exceptions and backtraces for every iteration
postmodern joined #ruby-lang
<Rich_Morin> if hash failures are unusual, there won't be many exceptions.
<Tasser> manveru, point for you ;-)
<manveru> i like going for worst-case :)
<rane_> Rich_Morin: why so adamant about using rescue?
<Rich_Morin> I think I explained that several minutes ago
<rane_> didn't notice any good points
<Rich_Morin> uhuh
workmad3 joined #ruby-lang
fish_ joined #ruby-lang
<fish_> hi
<rue> If Avdi actually recommends such an approach, I will set him on fire
robotmay joined #ruby-lang
<Rich_Morin> I would be interested to know what he thinks. In the meanwhile, it wouldn't be hard to whip up a method that does multi-level fetches, based on the number of input arguments.
<Rich_Morin> eg, mlf(hash, fail_value, arg1, arg2, arg3)
setmeaway2 joined #ruby-lang
darix joined #ruby-lang
darix joined #ruby-lang
hebz0rl joined #ruby-lang
rane_ joined #ruby-lang
nark-1 joined #ruby-lang
<nark-1> how to refactor this: list_of_bananas = [banana.slice(0..9), banana.slice(10..19), banana.slice(20..29)]
<nark-1> list_of_bananas is a string
locks joined #ruby-lang
<Asher> each_slice( 10 )
<nark-1> undefined method `each_slice'
<Asher> what is banana
<nark-1> string: "05012233440701223355"
<Asher> banana.chars.each_slice
<Asher> i believe
<Asher> yeah
<rippa> banana.chars.each_slice(10).map(&:join)
<Asher> yeah if you want the array of slices rather than just to iterate each slice
<nark-1> thanks much
<shevy> you have strange stuff in your bananas
burgestrand joined #ruby-lang
heftig joined #ruby-lang
Rich_Morin left #ruby-lang
Defusal joined #ruby-lang
Defusal joined #ruby-lang
madsheep joined #ruby-lang
leopard_me joined #ruby-lang
<manveru> >> "05012233440701223355".scan(/.{10}/m)
<manveru> => ["0501223344", "0701223355"]
<shevy> more bananas
dkannan joined #ruby-lang
<Asher> split those bananas in two
<rippa> manveru: breaks if length is not divicible by 10
jensn joined #ruby-lang
<shevy> manveru breaks bananas
saLOUt joined #ruby-lang
<ddfreyne> bananas?
<shevy> yeah
<shevy> heard of it?
<bnagy> scan(/.{1,10}/) then
<shevy> back in 2001 banans were the thing
adiblinux joined #ruby-lang
<shevy> *bananas
<shevy> but nowadays in the year 2053, bananas are rare
jensn joined #ruby-lang
madsheep joined #ruby-lang
Manhose joined #ruby-lang
Manhose_ joined #ruby-lang
NARKOZ joined #ruby-lang
Kanolesic joined #ruby-lang
jimmy1980 joined #ruby-lang
geoffw8_ joined #ruby-lang
cjs226 joined #ruby-lang
beiter joined #ruby-lang
geoffw8_ joined #ruby-lang
yalue joined #ruby-lang
Spooner joined #ruby-lang
rpall joined #ruby-lang
slyphon joined #ruby-lang
mark_locklear joined #ruby-lang
Manhose__ joined #ruby-lang
jimmy1980 joined #ruby-lang
m1d4s joined #ruby-lang
jbwiv_ joined #ruby-lang
nark-1 joined #ruby-lang
<shevy> dumdedum
<muzone> coke and rum
<muzone> cuz the day is young, girl u want some
Pip joined #ruby-lang
Pip joined #ruby-lang
malev joined #ruby-lang
<dr0id> f
jimmy1980 joined #ruby-lang
adiblinux joined #ruby-lang
<shevy> I suppose there is no easy way to convert ... 93822 seconds into HH:MM:SS format? Like 03:15:33
<shevy> I wrote a little class that does that, so it is solved for me, but I wonder if there is an easier way
<molgrew> what do you mean with easier way?
<molgrew> how easy is your way?
adiblinux left #ruby-lang
<shevy> molgrew well, the task to do the conversion is pretty simple, at threshold 60, overflow into the higher part (minutes to hours, seconds to minutes), but it's still like ... 15 lines of code in total. And ideally I'd rather like to try and use something in-built, or something shorter, rather than have to carry around this class in my projects :(
tommyvy__ joined #ruby-lang
macmartine joined #ruby-lang
yfeldblum joined #ruby-lang
gearaholic joined #ruby-lang
<manveru> 15?
<manveru> >> n = 93822; h, m = n.divmod(3600); m, s = m.divmod(60); "%02d:%02d:%02d" % [h,m,s]
<manveru> => "26:03:42"
mnoble joined #ruby-lang
mnoble left #ruby-lang
robbrit joined #ruby-lang
geoffw8_ joined #ruby-lang
mantono joined #ruby-lang
zerokarmaleft joined #ruby-lang
zerokarmaleft joined #ruby-lang
niklasb_ joined #ruby-lang
shevy joined #ruby-lang
Pupeno left #ruby-lang
leonL joined #ruby-lang
zerokarmaleft joined #ruby-lang
Indian joined #ruby-lang
looopy joined #ruby-lang
slyphon joined #ruby-lang
zerokarmaleft joined #ruby-lang
rippa joined #ruby-lang
scampbell joined #ruby-lang
outoftime joined #ruby-lang
MistyM joined #ruby-lang
uniqanomaly joined #ruby-lang
RomD` joined #ruby-lang
zerokarmaleft joined #ruby-lang
wi43 joined #ruby-lang
RomD joined #ruby-lang
<wi43> I have read in some LDAP data into an array and I have read into another array some data from a file. When i do @ldapdata-@filedata, the arrays are not compared. I am using the @filedata << line to read in data.
<wi43> Could it be because the types inside of the array are different, so they are not compared?
<wi43> they should both be strings
neilmiddleton joined #ruby-lang
<imperator> wi43, then you may need to flatten them before comparing, i.e. make sure you don't have nested arrays
<wi43> imperator, each element should just contain one word
<wi43> ill try and flatten
<wi43> and see real quick
<molgrew> you say should a lot
<imperator> wi43, i think what molgrew means is that it's up to you to make sure each element contains a single word then before comparing
<wi43> hehe - cheers
<wi43> agreed
imajes joined #ruby-lang
zerokarmaleft joined #ruby-lang
andrewhl joined #ruby-lang
vicegrip joined #ruby-lang
<wi43> aha.... i SHOULD of check that they were strings... thanks!
zerokarmaleft joined #ruby-lang
rayners joined #ruby-lang
Sailias joined #ruby-lang
ksinkar joined #ruby-lang
zerokarmaleft joined #ruby-lang
tomzx joined #ruby-lang
kmeehl joined #ruby-lang
zerokarmaleft joined #ruby-lang
dnjaramba joined #ruby-lang
zerokarmaleft joined #ruby-lang
jkyle joined #ruby-lang
looopy joined #ruby-lang
Sailias joined #ruby-lang
looopy_ joined #ruby-lang
Silowyi joined #ruby-lang
RomD` joined #ruby-lang
sepp2k joined #ruby-lang
yorickpeterse joined #ruby-lang
jasox joined #ruby-lang
ksinkar joined #ruby-lang
jimmy1980 joined #ruby-lang
gearaholic joined #ruby-lang
Natch| joined #ruby-lang
headius joined #ruby-lang
dejongge joined #ruby-lang
slyphon joined #ruby-lang
hebz0rl joined #ruby-lang
tenderlove joined #ruby-lang
ksinkar joined #ruby-lang
slackstation joined #ruby-lang
slackstation joined #ruby-lang
hagabaka joined #ruby-lang
hagabaka joined #ruby-lang
nofxx joined #ruby-lang
jimmy1980 joined #ruby-lang
srbaker joined #ruby-lang
scottschecter joined #ruby-lang
<headius> zenspider: I'm around to discuss the additional fixes
<manveru> shevy: you died?
thone_ joined #ruby-lang
io_syl joined #ruby-lang
jbsan_ joined #ruby-lang
steph021 joined #ruby-lang
steph021 joined #ruby-lang
butchanton joined #ruby-lang
nofxx joined #ruby-lang
io_syl_ joined #ruby-lang
io_syl_ joined #ruby-lang
wyhaines joined #ruby-lang
pbjorklund joined #ruby-lang
RomyEatsDrupal joined #ruby-lang
<pbjorklund> How can I write "session[:counter] ||= 0 ; session[:counter] += 1" in a less repetitive way?
io_syl joined #ruby-lang
vmatiyko joined #ruby-lang
io_syl_ joined #ruby-lang
<MistyM> pbjorklund: Is session a hash? I guess you could set a default value of 0 so you can increment keys that didn't previously exist, if you don't otherwise depend on accessing potentially undefined keys.
<pbjorklund> MistyM: Just looking for a nifty way to set it to something if nil and increment, otherwise just increment
<manveru> >> session = {}; session[:counter] = session[:counter].to_i + 1; session
<manveru> => {:counter=>1}
Pip joined #ruby-lang
Pip joined #ruby-lang
<MistyM> I didn't realize nil.to_i would return 0. Nifty!
RickHull joined #ruby-lang
RORgasm joined #ruby-lang
amerine joined #ruby-lang
tobiasvl joined #ruby-lang
<pbjorklund> manveru: Thanks, but doesn't that mean I have to repeat :counter twice in the line? Or did I miss something. Not really a ruby expert
savage- joined #ruby-lang
<manveru> pbjorklund: it does mean that
<manveru> once for setting, once for lookup
<pbjorklund> Ok so there is no ||=+(0,1) construct in ruby (yet)? :)
<manveru> i doubt it'll get one of those
<pbjorklund> My attempts at humor always goes unnoticed.. Thanks for helping out though manveru
<robbrit> what is ||= +(0,1) ?
FylGood joined #ruby-lang
<rippa> that actually would work
<rippa> it means the same as
<rippa> ||=0,1
heppy joined #ruby-lang
<rippa> nah
<rippa> comma messes it up
<manveru> kids these days... back in my days we'd have to carve each instruction into brittle stone tablets and feed them to the Interactive Broken Machine
Pip joined #ruby-lang
Pip joined #ruby-lang
towski joined #ruby-lang
lightcap joined #ruby-lang
darkf joined #ruby-lang
darkf joined #ruby-lang
WhiteHorse joined #ruby-lang
<shevy> manveru what
<shevy> I am alive and kicking ass!
lightcap joined #ruby-lang
heppy_ joined #ruby-lang
sodani joined #ruby-lang
<sodani> hello. open(url) creates a Tempfile object, and I'm wondering how I can then save this to a file
hagabaka joined #ruby-lang
nekid joined #ruby-lang
<Mon_Ouie> Tempfile are actual files somewhere in /tmp/ (or whatever is the temporary directory in your system)
jimmy1980 joined #ruby-lang
<Mon_Ouie> So you can just copy/move it as you want
<Mon_Ouie> (They have a #path method)
<sodani> ah I see that now. thanks!
<nekid> whats the command for finding out what something is?
<nekid> like finding out if its a class
<robbrit> nekid: obj.class
<nekid> ty
<steveklabnik> nekid: obj.is_a?(SomeClass)
<steveklabnik> obj.kind_of?(SomeClass)
lightcap joined #ruby-lang
gearaholic joined #ruby-lang
hagabaka joined #ruby-lang
RickHull joined #ruby-lang
<nekid> 2 spaces as an indent is more concise? than a tab?
dhoss_ joined #ruby-lang
<robbrit> nekid: 2 spaces is just a convention that the ruby community seems to use
<steveklabnik> yep.
<steveklabnik> two spaces, all the time.
dhoss_ joined #ruby-lang
jmontross joined #ruby-lang
Pip joined #ruby-lang
<shevy> ' '
<shevy> you may borrow but give it back one day
sodani left #ruby-lang
yorickpeterse joined #ruby-lang
heppy joined #ruby-lang
slackstation joined #ruby-lang
knu joined #ruby-lang
Oloryn_lt1 joined #ruby-lang
towski joined #ruby-lang
butchanton joined #ruby-lang
<nekid> does anyone know what a program is called that basically extracts and reorganizes the content of a website?
<robbrit> nekid: a scraper or crawler
<robbrit> hmm maybe not crawler
perryh joined #ruby-lang
<Tasser> nekid, reoganize in what way?
<nekid> basically, there are these science articles
<nekid> i want to organize it a different way(based on how i make the scraper?)
<Tasser> nekid, scraper: wget
LeoNerd joined #ruby-lang
<shevy> reorganizes?
<shevy> reorganize how
<LeoNerd> Hi all. Total meta-question: I have a question about the pastie.org paste site; it says on there this is where the bot lives. Is here a good place for that, or where would anyone suggest?
<nekid> so that it's useable in programs
<nekid> not for just reading knowledge
<shevy> what :)
<nekid> I don't know how, yet but will update you when I do
retro|cz joined #ruby-lang
<shevy> what kind of science articles are you trying to dig in nekid ?
<nekid> medicine
<shevy> cool
<nekid> still ways to go
<LeoNerd> Well, I'll ask anyway as it's quiet: Is there any way to pre-fill the syntax field of a new paste, perhaps by a URL parameter? I'd like to have a link that sets Perl automatically
<manveru> >> n = 93822; h, m = n.divmod(3600); m, s = m.divmod(60); "%02d:%02d:%02d" % [h,m,s]
<manveru> => "26:03:42"
<manveru> @ shevy
<shevy> whoa
<shevy> that's damn short
sepp2k joined #ruby-lang
<manveru> i could make it shorter, but it'd be a bit brainwrecking
<shevy> :(
<shevy> I wrote such a nice class! and a one-liner kills it
<shevy> hmm
<shevy> it's really short
<shevy> :)
<erikh> corundum: pickaxe?
<corundum> pickaxe is Programming Ruby, 3rd ed. by Dave Thomas, et al. Available for purchase (tree and pdf) at http://www.pragprog.com/ or at http://www.rubycentral.com/book/ (in first edition form) if you are a cheap bastard and hate kittens. or http://ruby-doc.org/docs/ProgrammingRuby/
marcostoledo joined #ruby-lang
roha joined #ruby-lang
cyndis joined #ruby-lang
Oloryn_lt1 joined #ruby-lang
<nekid> erikh: you can torrent pdf also
<shevy> eh
<shevy> where do you make your notes!
<shevy> the highlighting in colours!
<shevy> that's right
<shevy> on good old PAPER
<nekid> good reader app
<nekid> does that all too
<shevy> I no longer understand the world of today
<imperator> shevy == luddite
<shevy> what is that
<shevy> sounds italian
<rippa> luddite - enemy of science progress
<rippa> actually
<rippa> of technological
<imperator> rippa, not exactly
<rippa> In modern usage, "Luddite" is a term describing those opposed to industrialisation, automation, computerisation or new technologies in general.
<imperator> it's usually not used that severely though
<nekid> irb cannot display unicode on windows?
<rippa> more like
<nekid> my friends say lagger
<rippa> windows default command promtp cannot
<nekid> oh
<ReinH> I called someone a luddite on twitter once
<ReinH> they blocked me
<rippa> at least in my experience
LeoNerd left #ruby-lang
<imperator> think you gotta change your default code page
<imperator> can't remember now
sodani joined #ruby-lang
<ReinH> or your OS
cjs226 joined #ruby-lang
<imperator> nekid, chcp 65001
* imperator releases sys-uname 0.9.0 into the wild
nuclearsandwich joined #ruby-lang
<imperator> hm, i no longer see a way to set the default branch on a github project
<yxhuvud> can't you do it through git? I recall having been able to do it that way before
<yxhuvud> or maybe it was just master I set.
<nekid> imperator: where do you do that, i'm new
Codif joined #ruby-lang
<imperator> yxhuvud, it defaults to master
<imperator> nekid, on the windows command line
<imperator> yxhuvud, if there's a way to do it in git itself, i'm unaware how
<imperator> https://github.com/blog/421-pick-your-default-branch - i don't see that any more
<nekid> hmm i got some symbols, not the currency but better than \u00A5
<imperator> ReinH, how ironicle
shapeshed joined #ruby-lang
<imperator> yxhuvud, oh, found it, it's under "admin" now
gearaholic joined #ruby-lang
<imperator> nekid, what currency? euro symbol?
<rue> €
<nekid> yen
shapeshed joined #ruby-lang
hagabaka joined #ruby-lang
<imperator> might need to use a different cp then
<nekid> puts money = "\u{20AC}"
<nekid> gets me rho e w/ tilde and 1/4th
<ReinH> imperator: ?
ilyam joined #ruby-lang
<manveru> nekid: >> "\u20ac"
<manveru> => "€"
lsegal joined #ruby-lang
mytrile joined #ruby-lang
nofxx joined #ruby-lang
hhatch joined #ruby-lang
<nekid> "€"
Manhose joined #ruby-lang
brianpWins joined #ruby-lang
<manveru> nekid: what's your terminal?
nuclearsandwich joined #ruby-lang
bryanl joined #ruby-lang
fra000 joined #ruby-lang
workmad3 joined #ruby-lang
<queequeg1> Ruby koans are a good leaning experience. Are there any other collections of learning challenges like that?
twittard joined #ruby-lang
slyphon joined #ruby-lang
Codif joined #ruby-lang
<manveru> what's good material for getting into predictive input algorithms?
<bougyman> something written for lisp, i'd bet.
Jake232 joined #ruby-lang
<manveru> i wanna build something like what stephen hawkins uses for my mother
<nuclearsandwich> queequeg1: check Ryan Bates's Ruby Warrior gem.
<nuclearsandwich> I also like testfirst.org and rubymonk.com just launched their alpha.
<manveru> i.e. just a kind of joystick or eyetracking to select letters and have as much as possible predicted
<nuclearsandwich> If you want to play around in other languages and paradigms, Ruby Koans inspired the Clojure Koans project. Pretty sure there are coffescript/javascript koans now as well.
woollyams joined #ruby-lang
zkl joined #ruby-lang
r0bby joined #ruby-lang
<Spooner> nuclearsandwich: I found Rubywarrior recently. It was incredibly good :)
<nuclearsandwich> me too. I was updating the RailsBridge Learning Resources and thought "huh, what's this?"
<nuclearsandwich> then suddenly lost four hours of my day. :)
<nuclearsandwich> I had to put it away until finals are over
<Spooner> I put it away being stuck on the last level (intermediate-9). I need to go back to it and finish it.
srbaker joined #ruby-lang
benanne joined #ruby-lang
curtism joined #ruby-lang
nofxx joined #ruby-lang
robbrit left #ruby-lang
zmack joined #ruby-lang
Indian joined #ruby-lang
envygeeks joined #ruby-lang
Natch| joined #ruby-lang
<envygeeks> Is there a way to dup chain? EXP ENV.dup.delete('KEY')?
mksm_ joined #ruby-lang
<rue> manveru: ☹ Is there no commercially available software for that? Or do you just want it as a combined interesting experiment?
<RickHull> envygeeks: try it and see
<rue> Prediction might be a little under the wraps, I seem to recall it was a Big Competitive Advantage for e.g. Nokia back in the day
<envygeeks> RickHull... it failed that's why I'm asking :/
<rue> Failed how?
<RickHull> envygeeks: str = 'asdf'; str.dup.gsub('as', 'AS') #=> 'ASdf'
<rue> What does #dup do? It should return a new instance of the same class, with the same data
<RickHull> str #=> 'asdf'
<envygeeks> ENV.dup.delete('XAUTHORITY')
<envygeeks> NoMethodError: undefined method `delete' for #<Object:0x00000000dd3c68>
<RickHull> did you try without the dup?
<envygeeks> Doing delete on ENV without a dup is reckless
<rue> :D
<rue> You want two envs?
<RickHull> ENV.class == ENV.dup.class #=> true
<envygeeks> No, I just wanted to pull a variable like I do with ARGV where it will return nil or the value quickly
<rue> You probably need ENV#to_hash
<envygeeks> hmmm... actually I never thought of that let me try
postmodern joined #ruby-lang
<rue> ENV is *the* env
<RickHull> using delete to "pull" a variable seems like a funny idea
<RickHull> why not: ENV['asdf'] #=> nil
<RickHull> ENV['PATH'] #=> "/usr/local ..."
<erikh> ENV isn't a hash
<erikh> it just looks like one.
<erikh> oh I see from my second pass at the scrollback this has already been addressed
* erikh returns to his rock
jkyle joined #ruby-lang
<jorgenpt> Is there a nice way to deal with binary protocols that normally require pack/unpack etc, to nicely wrap it in something like a Struct?
<rue> There's a gem, I think
<rue> Also, depending on the use case, perhaps FFI may be more appropriate
<jorgenpt> It'd be cool to have a way to say something like Message = BinaryStruct.new(:foo, "v", :bar, "v"), and then be able to do Message.new(data).foo etc
hahuang65 joined #ruby-lang
<jorgenpt> Oh, maybe I want BitStruct
<rue> Slightly poorly named, but that's the one
srbaker joined #ruby-lang
workmad3 joined #ruby-lang
<Jake232> Can anyone help with the following?
<Jake232> history_buffer.rb: https://gist.github.com/1448664
<RickHull> L107 looks suspect on the .rb
<RickHull> er, nvm
<jorgenpt> Thanks rue :)
Pip joined #ruby-lang
Pip joined #ruby-lang
<rue> Jake232: when nil; …
<Jake232> rue: What's up with that?
<MistyM> Jake232: The full colon was tolerated syntax in Ruby 1.8, but doesn't work in 1.9. Use semicolons or then
<Mon_Ouie> It's not what is in your code
<Jake232> Ahh
<Jake232> That would explan it
<Jake232> Wow, this is annoying. It would seem this library
<Jake232> Uses this in alot of places
dv310p3r joined #ruby-lang
<RickHull> Jake232: congratulations on your new maintainership!
<Jake232> Did Ruby 1.8.x, accept semi-colons?
<Jake232> Or is that only 1.9.x?
<Mon_Ouie> Yes, it did
<Mon_Ouie> Also new-lines
<Jake232> Right, that's a safe fix then.
<MistyM> then also works in 1.8
<Jake232> Is there a preffered standard?
<Mon_Ouie> I use then when there is just one small expression in each case, new-line otherwise
<RickHull> agreed
<Jake232> AHh, it's not even on GitHub. Using RUbyForge, great :/
edwardsharp joined #ruby-lang
Wardrop joined #ruby-lang
<edwardsharp> is there some way i can check to see if nested hash key exists ( if hash[:foo].has_key?(:bar, :baz) ) so if hash[:foo] is nil i get a NoMethodError, can I check is_hash? or something similar in one if statement?
chessguy joined #ruby-lang
<edwardsharp> well, is_a?(Hash)
<rue> hash[:foo] && hash[:foo][:bar] +
<rue> ?
<edwardsharp> oh &&, of course!
<edwardsharp> thx
kennyp joined #ruby-lang
fridim_ joined #ruby-lang
dr_bob joined #ruby-lang
adambeynon joined #ruby-lang
dejongge joined #ruby-lang
<queequeg1> nuclearsandwich: Thanks for the recommendation
adambeynon joined #ruby-lang
<andrewvos> omfg I just installed oh-my-zsh
leonL joined #ruby-lang
<deryldoucette> careful if using RVM. The RVM plugin with oh-my-zsh needs work. that and the bundler one
gix joined #ruby-lang
<andrewvos> deryldoucette: Careful how?
<edwardsharp> overwriting you .zshrc
<edwardsharp> your
<deryldoucette> also, mpapis is going to work with the omz author to fix the plugin
<edwardsharp> looks neat, tho. wonder if there's a bash flavor
<deryldoucette> not sure if he's gotten to that yet. he's been seriously busy
<andrewvos> WTH I don't even have to cd
apeiros_ joined #ruby-lang
Austin__ joined #ruby-lang
roha joined #ruby-lang
kennyp joined #ruby-lang
jimmy1980 joined #ruby-lang
rafaelchacon joined #ruby-lang
workmad3 joined #ruby-lang
<rafaelchacon> Hello
zzak joined #ruby-lang
<rafaelchacon> I'm founding an issue with URI.extract in both ruby 1.8.7 and ruby 1.9.2
mksm joined #ruby-lang
<drbrain> rafaelchacon: show it!
<rafaelchacon> If you try to extract un URI from the following text:
<rafaelchacon> It returns: ["on:"] as un URI
<rafaelchacon> as an*
<rafaelchacon> So I don't know if this is an expected behavior
<andrewvos> rafaelchacon: Probably
<andrewvos> rafaelchacon: If you're looking for http: just check if the string includes it.
jasox joined #ruby-lang
<manveru> rafaelchacon: extract takes another argument
<drbrain> rafaelchacon: in 1.9 you can do URI.extract string, schemes: %w[http https]
<drbrain> I don't know about 1.8
<drbrain> oops
kyrylo joined #ruby-lang
<manveru> without the schemes:
<drbrain> rafaelchacon: ruby -ruri -e 'p URI.extract $stdin.read, %w[http https]'
<drbrain> manveru: yeah
<rafaelchacon> but I don't want to limit it to an specific scheme
<drbrain> rafaelchacon: so it probably looks for any valid scheme
<rafaelchacon> oh ok
<drbrain> rafaelchacon: then what's the problem?
<drbrain> on: is a valid scheme name
<rafaelchacon> let me try with http and https
<rafaelchacon> I didn't know you can pass several
<rafaelchacon> OH yeah that works
<rafaelchacon> thanks a lot!
<drbrain> sweet
<rafaelchacon> :)
RomD` joined #ruby-lang
oilpastels_ joined #ruby-lang
<headius> zenspider: around?
dmartenson joined #ruby-lang
rafaelchacon left #ruby-lang
fridim_ joined #ruby-lang
cjs226 joined #ruby-lang
heppy_ joined #ruby-lang
Axsuul joined #ruby-lang
<envygeeks> There must be a better way than %x{} or `` which taints the SH output severely
outoftime joined #ruby-lang
<drbrain> envygeeks: popen?
<envygeeks> hmmm... good idea
petercooper joined #ruby-lang
flip_digits joined #ruby-lang
woollyams joined #ruby-lang
workmad3 joined #ruby-lang
mantono joined #ruby-lang
nofxx joined #ruby-lang
sodani1 joined #ruby-lang
oilpastels joined #ruby-lang
BinaryMuse joined #ruby-lang
BinaryMuse left #ruby-lang
srbaker joined #ruby-lang
flip_digits joined #ruby-lang
tallship joined #ruby-lang
tenderlove joined #ruby-lang
Carnage\ joined #ruby-lang
RomyEatsDrupal joined #ruby-lang
RickHull left #ruby-lang
sodani1 left #ruby-lang
outoftime joined #ruby-lang
<queequeg1> So what is the difference between object.method and object#method ?
<erikh> just a notational one
<erikh> object.method is typically used to describe a class method and object#method is used to describe an instance one
<queequeg1> ah, thanks.
srbaker joined #ruby-lang