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