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/
<kandinski>
I was precisely experimenting with a hash of default empty arrays
<kandinski>
so Hash[0] is illegal, it has to be Hash.new 0
<kandinski>
but when you make a Hash from zipping two arrays, you can call it either way
<gytis_z>
banister_: thanks!
<gytis_z>
kandinski: very interesting
<kandinski>
Hash[k.zip(v)] or Hash.new k.zip(v)
<kandinski>
gytis_z: I am a noob, even my question could be wrong
<kandinski>
ah
burns180_ has joined #ruby
<kandinski>
Hash[] creates a new array from an array of pairs, or an array of k,v,k2,v2 etc
<kandinski>
Hash.new creates an empty array with a default value
dnyy has joined #ruby
<kandinski>
an empty hash with the default value of an empty array, I mean
jamesaxl has joined #ruby
booginga has joined #ruby
tommyvyo has joined #ruby
<kandinski>
so [] can mean in ruby: 1) subscript for hashes and arrays, 2) synonym for .call (in procs), 3) generate new object and populate from given arguments (in the case of Hash, for instance). Any other possible meaning of []?
apeiros_ has joined #ruby
<RegEchse>
kandinski: i'd suggest reading through ri '[]' ;)
zul has joined #ruby
<kandinski>
RegEchse: oh
<kandinski>
thanks
zul has joined #ruby
<kandinski>
RegEchse: you can tell I'm new, I just did ri '[]' in irb and got an undefined local error
noyb has joined #ruby
havenn has joined #ruby
zul has joined #ruby
nopolitica has joined #ruby
<RegEchse>
kandinski: ri is a separate program; from the man page: "ri — Ruby API reference front end"
<kandinski>
oh, right, ta
nopolitica has joined #ruby
nopolitica has joined #ruby
<kandinski>
RegEchse: nothing known about [], but thanks for the tip anyway. I'll use it often.
redgetan has joined #ruby
pu22l3r_ has joined #ruby
kyledr has joined #ruby
io_syl has joined #ruby
lkba has joined #ruby
fixl has joined #ruby
CacheMoney has joined #ruby
steve1 has joined #ruby
burns180 has joined #ruby
boondox has joined #ruby
albemuth has joined #ruby
<gid0>
am I missing a paramater?
mikeric has joined #ruby
thone has joined #ruby
* tommylommykins
stares at symbols
<tommylommykins>
I guess there's not really all that many operations that can be performed on symbols
neurodrone has joined #ruby
fayimora has joined #ruby
UForgotten has quit [#ruby]
codezombie has joined #ruby
kyledr_ has joined #ruby
jaminkle has joined #ruby
MasterBob has joined #ruby
Banistergalaxy has joined #ruby
burns180_ has joined #ruby
looopy has joined #ruby
superguenter1 has joined #ruby
jacktrick has joined #ruby
zulax has joined #ruby
stringoO has joined #ruby
akem_ has joined #ruby
<MasterBob>
Hello. Is abort the clean way to gracefully exit a Ruby program?
<cout>
exit()
<deryldoucette>
exit, or return if its the last
<MasterBob>
Why use exit() instead of abort?
<deryldoucette>
think about it
<deryldoucette>
what does abort signify to you? usually an error or a problem right?
<MasterBob>
Hold on.
phantomfakeBNC has joined #ruby
<deryldoucette>
most of the words selected generally make sense if you think of them in a real world situation.
<MasterBob>
But if my program expects only 2 parameters and I want to exit if I don't receive two parameters...I'd want to use exit then, as that's how it's designed.
<MasterBob>
oh-kay.
<MasterBob>
thanks
<deryldoucette>
some aren't quite sensible (at least to me) but the VAST majority are bang on.
tommyvyo has joined #ruby
<deryldoucette>
no then you would use abort
<deryldoucette>
that would make sense then
<deryldoucette>
you're aborting because of a problem or error. in this case the lack of something thats needed
<deryldoucette>
I would question exit then
<MasterBob>
okay.
badabim has joined #ruby
<MasterBob>
Do I have to explicitly state exit at the end of my program then?
<deryldoucette>
no because ruby falls through with the last instruction
<deryldoucette>
You might want to if you want to be pedantic but its not needed if you're just ending the program
<MasterBob>
Okay. thanks deryldoucette
<deryldoucette>
no problem :)
<mythmon>
with StringScanner, can i match a string, but return only a subset of it?
<mythmon>
in particular, I want to match a quoted string, but then not include the quotes.
<deryldoucette>
for ME i try to make things semantically straight. i try to keep as close to what woul dbe natural english both in thought and form
<deryldoucette>
doesn't mean you HAVE to, just that i think by doing that it helps you in the thought process behind what you're doing as well
<deryldoucette>
like slice, map, ect don't *quite* match what i would use for natural english (my native language) but i completely understand why they DID choose the words.
<deryldoucette>
and no, while i disagree with the terms i don't have better ones to suggest. :/
<deryldoucette>
thus why i've not offered patches heheh
albemuth has joined #ruby
c0rn has joined #ruby
yoklov has joined #ruby
Banistergalaxy has joined #ruby
rexbutler has joined #ruby
<rexbutler>
Question: would ruby optimize something like [xv,yv].min > 0 to xv > 0 and yv.min > 0 or something like
<mythmon>
rexbutler: probably not
<rexbutler>
mythmon: Hmm
<mythmon>
or, simpler, how can I chop the first and last characters off a string?
<rexbutler>
mythmon: Can't you just slice out the right portion?
kyledr has joined #ruby
<mythmon>
in python i would say [1:-1], but it doesn't appear to work like that in ruby.
<rexbutler>
your_string[1..-1] doesn't work?
<pastjean>
mythmon: you can actually a = "\"asd\"" a
<pastjean>
[1..-2]
<pastjean>
since -1 is the last character and is the quote
<mythmon>
ah, ok. i tried [1,-2]
<pastjean>
"\"asd\""[1..-2]
<mythmon>
yeah, thanks.
ap0gee has joined #ruby
<pastjean>
mythmon: no problems
<rexbutler>
pastjean: or better, my_string[1...-1]
<mythmon>
in python it is -1, because its not inclusive of the end. 1.-2 works great
<mythmon>
er, 1..-2
<pastjean>
rexbutler: that's what I was meaning tough it's not -1 but -2
<rexbutler>
pastjean: I mean, if you use '...' not '..' it doesn't include the character at the last index
<pastjean>
ahhh did not know that trick :)
<Quadlex>
So, load paths
waxjar has joined #ruby
<Quadlex>
When loading a gem, /lib is added to the load path
<Quadlex>
So what's the best practice for writing the gem during testing, manually adding /lib to the load path in your tests?
btanaka has joined #ruby
banister_ has joined #ruby
liluo has joined #ruby
phantomfakeBNC has joined #ruby
burns180 has joined #ruby
dagnachewa has joined #ruby
AndChat- has joined #ruby
btanaka has joined #ruby
<MasterBob>
Does ruby have a version of the C++ vector?
arvidkahl has joined #ruby
<banister_>
MasterBob: what features are oyu looking for
nari has joined #ruby
<MasterBob>
just the ability to hold an unspecified number of variables
<pastjean>
MasterBob: the normal array can do that
<nobitanobi>
given an array like this [{"id" => 1, "value" => 10},{"id" => 2, "value" => 20} ... ] - How can I add all the values without having to do an each ?
<xrfang>
hi, I installed ruby1.8 on ubuntu, and then do a gem install rdoc, but rdoc refused to be upgraded, after install 3.1.2, the system still use v1.0.1 comes with the ruby1.8 deb installation. why?
apeiros_ has joined #ruby
nobitanobi has joined #ruby
nopolitica has joined #ruby
ap0gee has joined #ruby
pu22l3r has joined #ruby
pu22l3r has joined #ruby
bigkm has joined #ruby
ed_hz_ has joined #ruby
burns180 has joined #ruby
dlam has joined #ruby
odinswand has joined #ruby
cantbecool has joined #ruby
cantbecool has quit [#ruby]
vraa has joined #ruby
igotnolegs has joined #ruby
apeiros has joined #ruby
nobitanobi has joined #ruby
Bosma has joined #ruby
_jak has joined #ruby
_jak has quit [#ruby]
Corey has joined #ruby
nobitanobi has joined #ruby
jankly has joined #ruby
chimkan__ has joined #ruby
rramsden has joined #ruby
sroy2_ has joined #ruby
sohocoke has joined #ruby
nobitanobi has joined #ruby
sohocoke_ has joined #ruby
Sailias has joined #ruby
odinswand has joined #ruby
paydro has joined #ruby
nobitanobi has joined #ruby
albemuth has joined #ruby
burns180_ has joined #ruby
nobitanobi has joined #ruby
Phrogz has joined #ruby
nfluxx has joined #ruby
heftig has joined #ruby
<shevy2>
xrfang probably your ubuntu version interferes
<shevy>
ubuntu hates if you dont use their way
<xrfang>
shevy2: yes I found there is a rdoc under /usr/bin, which is not in the gem way. and there is a gem one under /usr/local/bin
blazento has joined #ruby
<shevy>
well one is the wrong one I suppose
<shevy>
also upload the output of `gem env`
<shevy>
also of the gem in /usr/local/bin and compare the two
<shevy>
you should ask the ubuntu guys how to use gems the ubuntu-way. as they create the mess in the first place
<banister_>
shevy: sup markus
<shevy>
banister_ hey I am poaching another ubuntu victim right now!
<banister_>
shevy: do you consider yourself evil and german
<shevy>
those poor souls are eternally scorched by the unholy flame that burns in ubuntu
<shevy>
evil is relative
Seisatsu has joined #ruby
<xrfang>
ok, I will continue the ruby way, instead that I am reluctant to compile ruby myself.
<xrfang>
seem all ok, until I try to start the webrick server
<xrfang>
e.g. ruby script/server webrick -e production
<xrfang>
btw, I am trying to install the redmine server
<shevy>
well it can always lead to confusion when your system is messed up
<shevy>
you can:
<shevy>
(a) stick to the debian way
<xrfang>
the above command generated an eacces error, on the /var/www/redmine/tmp/pids file. my question is, do webrick usually run as ROOT?
<shevy>
(b) get rid of the old ruby and compile ruby for yourself into i.e. /usr prefix, but you probably have to get some header files before you can compile things
<libertyprime>
Hey guys. I don't know why ruby isn't finding sqlite3 in my script. At the top of my script I have "require 'sqlite3'", and the gem has been installed. However it's giving me "no such file to load". How can I figure out what's going wrong?
<xrfang>
shevy, RVM sounds interesting. I will take a look now
<shevy>
(d) try to find the proper version to call (or just kill the wrong gem or wrong gem paths, but I never tried that)
<shevy>
xrfang, I don't think so. I think you can run webrick without being root
<shevy>
it's just a webserver that comes with ruby, so if you are able to use ruby as non-root, webrick should work as well
<shevy>
but perhaps you had no user access to that directory
<xrfang>
hm... a quick browse I found RVM maybe overkilling, I will take your advice (b).
<shevy>
yay :)
<shevy>
it's what I did
<xrfang>
but first, I would like to understand why webrick is "access denied".
<shevy>
I got rid of all of ruby that debian had and compiled into /usr (though actually, I compile into a versioned directory, a bit how RVM does too)
<xrfang>
noticed that in step 7, it chmod the tmp folder to 755, but then webrick complains no access...
<xrfang>
shevy, no I just downloaded redmine directly.
<xrfang>
shall I install using gem?
<shevy>
I dont know
<shevy>
I dont think I installed redmine before
<shevy>
ERROR: Could not find a valid gem 'redmine' (>= 0) in any repository
<shevy>
ERROR: Possible alternatives: redline, radmin, rediline, redcuine, redmiso
<shevy>
it does not seem to exist as gem
<xrfang>
ok
Natch| has joined #ruby
<xrfang>
I tried to ask the same question on #redmine, now will try to do a clean installation of ruby...
nobitanobi has joined #ruby
<libertyprime>
ignore my last question. worked it out -.-
td123 has joined #ruby
btfriar has joined #ruby
snip_it has joined #ruby
c0rn has joined #ruby
nobitanobi has joined #ruby
pu22l3r_ has joined #ruby
xrfang has joined #ruby
macmartine has joined #ruby
looopy has joined #ruby
caiges has joined #ruby
nikhil_ has joined #ruby
rburton- has joined #ruby
burns180 has joined #ruby
nobitanobi has joined #ruby
arvidkahl has joined #ruby
Transcended has joined #ruby
nobitanobi has joined #ruby
demian`_ has joined #ruby
adeponte has joined #ruby
Jay_Levitt has joined #ruby
nobitanobi has joined #ruby
JNZ` has joined #ruby
nobitanobi has joined #ruby
EvanR has joined #ruby
thebastl has joined #ruby
j3r0m3 has joined #ruby
Banistergalaxy has joined #ruby
gogiel has joined #ruby
pielgrzym has joined #ruby
startling has joined #ruby
j3r0m3 has joined #ruby
iamjarvo has joined #ruby
ceej has joined #ruby
<iamjarvo>
does anyone have a good article on ruby and immediate values ?
j3r0m3 has joined #ruby
yeltzooo has joined #ruby
startling has quit [#ruby]
russfrank has joined #ruby
blazento has joined #ruby
j3r0m3 has joined #ruby
ged has joined #ruby
j3r0m3 has joined #ruby
libertyprime has joined #ruby
fismo has joined #ruby
timonv has joined #ruby
rohit has joined #ruby
nobitanobi has joined #ruby
nikhil_ has joined #ruby
cantbecool has joined #ruby
arvidkahl has joined #ruby
nobitanobi has joined #ruby
cantbecool has joined #ruby
rippa has joined #ruby
burns180_ has joined #ruby
mdel has joined #ruby
nobitanobi has joined #ruby
gokul has joined #ruby
waxjar has joined #ruby
nobitanobi has joined #ruby
AndChat| has joined #ruby
pp01bit has joined #ruby
pen has joined #ruby
nobitanobi has joined #ruby
banistergalaxy has joined #ruby
j3r0m3 has joined #ruby
nobitanobi has joined #ruby
snip_it has joined #ruby
Zolrath has joined #ruby
AndChat- has joined #ruby
nobitanobi has joined #ruby
AndChat| has joined #ruby
k_89_ has joined #ruby
arvidkahl has joined #ruby
nobitanobi has joined #ruby
burns180 has joined #ruby
nobitanobi has joined #ruby
camilo_ has joined #ruby
<camilo_>
Any way for a mock to yield with just minitest or do I need to bring mocha in?
booginga has joined #ruby
nobitanobi has joined #ruby
macmartine has joined #ruby
S0lign0c has joined #ruby
mikeric has joined #ruby
noyb has joined #ruby
apeiros_ has joined #ruby
kevinbond has joined #ruby
arvidkahl has joined #ruby
rohit has joined #ruby
guns has joined #ruby
krz has joined #ruby
dross has joined #ruby
bier has joined #ruby
AndChat- has joined #ruby
pen has joined #ruby
burns180_ has joined #ruby
eldariof has joined #ruby
drake10 has joined #ruby
nobitanobi has joined #ruby
<nikhil_>
hi
<nikhil_>
anyone around?
<nikhil_>
I have a question about super()
<nikhil_>
I am doing SaaS class from coursera
nobitanobi has joined #ruby
dross_ has joined #ruby
<nikhil_>
When they call super in method_missing, they don't pass it any arguments
<nikhil_>
and somehow the superclass just 'gets' the method_id and args
k_89_ has joined #ruby
DrShoggoth has joined #ruby
<nikhil_>
however, i have seen ruby code where the superclass is passed arguments via super
<nikhil_>
what is the mechanism behind this -- how to think about it?
<banistergalaxy>
nikhil_: you can do both, if you invoke super without any args it automatically just passes up the same args it received in the subclass
<banistergalaxy>
nikhil_: however if you explicitly pass up args then the superclass *only* gets those args
<banistergalaxy>
nikhil_: again, it's ruby optimizing for the common case :)
<banistergalaxy>
most cases you will just want to pass up the same args u got, so it would be annoying just typing that out each time
<nikhil_>
banistergalaxy, so it would be legal to have a constructor in a child class which just initialized its own variables (even though it is passed those belonging to the super) and then just call super?
<banistergalaxy>
but, in the case you wnat to pass up different args, then ruby allows that too
<nikhil_>
yeah, ruby is really cool man
<nikhil_>
and i thought python was awesome
<nikhil_>
^_^
<nikhil_>
i thought it was something i would be doing because i wanted to learn SaaS, but here I am considering so many things --- it's opening up my mind in so many ways
yoklov has joined #ruby
<banistergalaxy>
cool
<banistergalaxy>
nikhil_: wait till you learn about metaprogramming, then things get fun :)
<nikhil_>
banistergalaxy, we are learning about metaprogramming! it's amazing!
<nikhil_>
although I am struggling with class_eval a bit
<nikhil_>
that bit while you're trying to wrap your brain around something before it all actually wraps
hamcore has joined #ruby
nobitanobi has joined #ruby
Transcended has joined #ruby
<banistergalaxy>
nikhil_: Yeah, you'll get there just test a lot of stuff out in the repls (irb or pry)
<banistergalaxy>
nikhil_: i recommend pry ;) :D
<nikhil_>
while i'm taking the course they use irb so i'll stick to that. pry is another interpreter?
nobitanobi has quit [#ruby]
nfluxx has joined #ruby
<banistergalaxy>
nikhil_: pry is exactly like irb, but 50x more powerful http://pry.github.com
<banistergalaxy>
nikhil_: you might even get an advantage if you use it (it wont set u back, since all the instructions for irb will still work)
CheeToS has joined #ruby
<nikhil_>
banistergalaxy, i'll take a look
<nikhil_>
banistergalaxy, do you know anything about metaprogramming using class_eval?
<banistergalaxy>
nikhil_: yep
<nikhil_>
how exactly are you supposed to define a method inside a string?
looopy has joined #ruby
billgui has joined #ruby
<banistergalaxy>
nikhil_: are you using string evals rather than block-based evals?
<nikhil_>
i'm not asking you for an answer -- that would be against the code of conduct
<Mon_Ouie>
krz: it creates an array with all the elements of the range
<Mon_Ouie>
i.e. it's much slower
<nikhil_>
banistergalaxy, hmm
<banistergalaxy>
nikhil_: updated it, i had an unnecessary line in there
<banistergalaxy>
nikhil_: Yep, their hint solution code is stupid
<banistergalaxy>
imo
<nikhil_>
why's that?
<banistergalaxy>
nikhil_: because it doenst need to use string-based evals
<nikhil_>
banistergalaxy, is there any reason they could be asking us to do that? and our solution has to use string based evals because it's marked by a computer
<banistergalaxy>
nikhil_: probably because they dont know about instance_variable_set
<nikhil_>
i'm still not understanding programmatically what's going on...
x0F__ has joined #ruby
sleetdrop has joined #ruby
<shevy>
ewwwww
<shevy>
evals
greenarrow has joined #ruby
iMe has joined #ruby
ryanf has joined #ruby
<shevy>
hmm
<shevy>
a goto within an evail
<shevy>
eval
OpenJuicer has joined #ruby
<shevy>
now that would be something
<banistergalaxy>
Mon_Ouie: sup monny
<banistergalaxy>
Mon_Ouie: how's your objc chops?
<ryanf>
banistergalaxy: how's your obj-c coming anyway?
Morkel has joined #ruby
banistergalaxy has joined #ruby
manizzle has joined #ruby
<banistergalaxy>
ryanf: pretty good, im about 1-2 chapters a day
<banistergalaxy>
ryanf: just still getting a sense of things like memory management and so on
<banistergalaxy>
before i start
jimmy has joined #ruby
<banistergalaxy>
ryanf: what's up
baroquebobcat has joined #ruby
<ryanf>
not a lot
<ryanf>
my phone got stolen :(
<ryanf>
luckily, apparently I signed up for insurance and then forgot about it
burns180_ has joined #ruby
<banistergalaxy>
ryanf: oh you didnt install a phone locator app?
<banistergalaxy>
ryanf: if anyone steals my phone i can hunt them down on gps
<banistergalaxy>
:))
<ryanf>
I did actually. I told the cops where the little dot is
<ryanf>
I'm not gonna go like hunt it down
<banistergalaxy>
ryanf: you should go around to the house with a few of your homies
<ryanf>
yeah good plan
<ryanf>
on the bright side, when I chased after the guy who took it, I completely forgot about my guitar and left it on the subway
<ryanf>
and someone turned it in to the lost and found
wadkar has joined #ruby
<wadkar>
can I define a method in a class which is private ? I haven't come across private/public/protected identifier in Ruby yet, thats why I ask
<ryanf>
yes, just put "private" or "protected" above the definition of the method
<ryanf>
every method definition from that point onward will have the given privacy
<ryanf>
the definitions are a little weird though, I recommend looking them up so you understand what you're actually getting
<wadkar>
ryanf: and by default methods are public? whatif I want to selectively give a method some_privacy?
<banistergalaxy>
ryanf: so he literally just ripped it out of your hands?
<ryanf>
banistergalaxy: yeah, I wasn't holding it very tightly I guess
<ryanf>
he and his buds were getting off the train and he just took it on the way by
<ryanf>
I also got very slightly pepper sprayed, which was interesting
<banistergalaxy>
ryanf: haha
<banistergalaxy>
ryanf: do police act on the gps locator? or i guess they cant be assed
<wadkar>
ryanf: thanks, I read the docs, and I can give arguments to the private/protected statement as name of the method, which I want to declare as private/public
<FFForever>
How can I can run sort on a string and turn ababa to aaabb?
<rippa>
string.chars.sort
<FFForever>
thanks! I've been racking my head on that.
<artOfWar>
any reason why list of symbols have to be converted to strings and compare against the string value rather than comparing against the symbols directly?
<rippa>
artOfWar: because if you compare against symbol, you create that symbol even if it wasn't present
burns180 has joined #ruby
GoBin has joined #ruby
<artOfWar>
rippa: in the above case where I pasted the link, we are first putting all the symbols into an array and then checking if it has a we are looking for, so in this case even if we create a symbol on the symbol table it shouldn't matter as we already have a snapshot of our symbol table's previous state
<artOfWar>
rippa: correct me if I'm wrong
<rippa>
artOfWar: try it yourself
<rippa>
it is created when the method definition is executed
<wadkar>
guys, this pry thingy is cool, I can look up the definitions, and docs, this is way cool than irb !
<banistergalaxy>
wadkar: yeah, it makes my dick hard.
michal_sz has joined #ruby
Zolrath has joined #ruby
Teomari has joined #ruby
burns180_ has joined #ruby
burgestrand has joined #ruby
mechanicalturk has joined #ruby
nikhil_ has joined #ruby
ap0gee has joined #ruby
timonv has joined #ruby
<banistergalaxy>
wadkar: did u watch the screencast
<nikhil_>
banistergalaxy, i ended up not using your implementation and using class_eval strings...
<nikhil_>
but thanks for the help
<banistergalaxy>
nikhil_: np
<banistergalaxy>
nikhil_: can i see your code
<nikhil_>
sure
mfridh has joined #ruby
looopy has joined #ruby
shruggar has joined #ruby
<banistergalaxy>
nikhil_: ?
mafolz has joined #ruby
<nikhil_>
pm...
<nikhil_>
banistergalaxy, ^^
FND has joined #ruby
heftig has joined #ruby
timonv_ has joined #ruby
ph^ has joined #ruby
schovi has joined #ruby
<FND>
how can I make bundler use ~/.gem instead of /usr/lib/ruby/gems? (I recently abandoned RVM since I only need Ruby 1.9 these days)
headius has joined #ruby
matt__ has joined #ruby
<matt__>
Hy guys, I've been struggling on something for the last hour, can someone help me please
<matt__>
I'm tryin gto achieve this assert_equal true, false
<matt__>
I've tried to monkey patch TrueClass, update the TRUE constant value but no success
<matt__>
but I know it's possibl
<matt__>
e
mikeric has joined #ruby
KL-7 has joined #ruby
Avanine has joined #ruby
<matt__>
assert_equal(true, false)
<matt__>
anyone?
shruggar has joined #ruby
Mchl has joined #ruby
nikhgupta has joined #ruby
sspiff has joined #ruby
zommi has joined #ruby
burns180 has joined #ruby
nachtwandler has joined #ruby
Playb3yond has joined #ruby
omry_ has joined #ruby
yeggeps has joined #ruby
twqla has joined #ruby
pen has joined #ruby
gianlucadv has joined #ruby
scalebyte has joined #ruby
<scalebyte>
this code isnto wroking : unless @user.about_me.length > "100"
<scalebyte>
this code isnto wroking : unless @user.about_me.length > 100
<banistergalaxy>
scalebyte: leave now and never come back!!!!!!!!!
dekroning has joined #ruby
<scalebyte>
banistergalaxy: my mistake i wanted < instaed of > sorry
LMolr has joined #ruby
trivol has joined #ruby
rpgsimmaster has joined #ruby
blacktulip has joined #ruby
KL-7 has joined #ruby
Helius has joined #ruby
FND has quit [#ruby]
AxonetBE has joined #ruby
<scalebyte>
banistergalaxy: why did u say that ?
<banistergalaxy>
scalebyte: because i think you're a dick
<scalebyte>
banistergalaxy: u hardly know me
<banistergalaxy>
scalebyte: just on this channel then :)
<scalebyte>
banistergalaxy: please talk properly.. I have just started learning ruby so some of my doubts might seems very stupid to you guys.. that's understandable
<banistergalaxy>
scalebyte: a few reasons, mainly because the majority of your questions are rails-related on a non-rails channel, also because your questions are usually phrased in such obscure ways that no one would help you anyway.
<scalebyte>
banistergalaxy: I always keep my questions simple... anyway since you made this statement, I will definitely try and improve on those points.. Thanks
<poppiez>
how do you pass array parameters to a rake task?
<poppiez>
I want to pass a bunch of file paths to a task
mklappstuhl has joined #ruby
Talvino has joined #ruby
sdeobald has joined #ruby
burns180 has joined #ruby
iocor has joined #ruby
nari has joined #ruby
pp01bit has joined #ruby
chimkan__ has joined #ruby
<wadkar>
is there a method for array meaning include?(all_elements_of_this_array)
iocor has joined #ruby
wulfgarpro has joined #ruby
d3vic3 has joined #ruby
jlebrech has joined #ruby
canton7 has joined #ruby
<rippa>
wadkar: what?
<wadkar>
a = [1,2,3,4] ; b = [1,2] ; a.some_method?(b) #=> true as a contains all of b; b = [1,5]; a.some_method?(b) #=> false as a does not contain all of b
alem0lars_ has joined #ruby
<rippa>
b.all? {|i| a.include? i}
Natch| has joined #ruby
bondar has joined #ruby
visof has joined #ruby
visof has joined #ruby
Natch| has joined #ruby
<wadkar>
rippa: ohh, block with all? and compare, I was thinking on the lines of reject block, and lesson (re)learned, negations are hard to grasp at first hand
Norrin has joined #ruby
<banistergalaxy>
wadkar: instead of spending time learning ruby why dont u take silver in the arm and walk head-high on highways
d3vic3 has joined #ruby
gianlucadv has joined #ruby
heftig has joined #ruby
fayimora has joined #ruby
zul_ has joined #ruby
<wadkar>
banistergalaxy: I don't understand 'take silver in the arm ...'
Ferdev has joined #ruby
Shrink has joined #ruby
<cout>
silver == a bullet
<banistergalaxy>
wadkar: inject heroin
mengu has joined #ruby
<cout>
oh
<cout>
never mind
<cout>
wrong metaphor L)
<banistergalaxy>
cout: hehe, or just me choosing the wrong words ;)
pen has joined #ruby
* wadkar
is clueless
iocor has joined #ruby
<cout>
me too
<banistergalaxy>
nm, im drinking whiskey with my flatmate and talking nonsense
visof has joined #ruby
<banistergalaxy>
cout: do you have any experience with objc?
d3vic3 has joined #ruby
<cout>
not really
simao has joined #ruby
igaiga has joined #ruby
fayimora has joined #ruby
A124 has joined #ruby
nikhgupta has quit [#ruby]
tvw has joined #ruby
burns180_ has joined #ruby
Ammar01 has joined #ruby
<LMolr>
is there a collect variant that gives a Set instead of an Array?
n1x has joined #ruby
<Tasser>
LMolr, require 'set'
<banistergalaxy>
Tasser: just call to_set on the result
aibo has joined #ruby
pencilcheck has joined #ruby
snearch has joined #ruby
<LMolr>
i'm not expert in ruby internals (neither external, really), but wouldn't this be inefficient instead of a native set collect?
<LMolr>
(wow my english is awesome today)
sdeobald has joined #ruby
justinmcp has joined #ruby
Vadim2 has joined #ruby
alup has joined #ruby
virunga has joined #ruby
virunga_ has joined #ruby
ephemerian has joined #ruby
<banistergalaxy>
LMolr: there is no native set collect, cos sets are a rarely used datatype they didnt think to build them into core
<banistergalaxy>
datastructure
<LMolr>
banistergalaxy: ok, thanks. I'm using a set to keep an unordered list of children in a composite structure, and using collect to walk children and collect values.
<philcrissman|afk>
scalebyte: you don't understand what I'm saying; that syntax is wrong. It doesn't say what you think it says. It will return d. Which is true.
<scalebyte>
eddie_: philcrissman|afk thanks... I will try and correct the code
<eddie_>
scalebyte: i am not using or or || in the conditions
<eddie_>
check that
<eddie_>
check the pastie
<wadkar>
bit puzzled : http://pastie.org/private/cchi64uuqxgjvsopm0qxq ; the debugger tells me that it is evaluating if Movies.attribute_names.include? conditional when it should be short-circuited; or am I reading something wrong in the debugger ?
<scalebyte>
eddie_: ya am checking it :)
<eddie_>
ok
mdw has joined #ruby
<philcrissman|afk>
eddie_: yep, include? is the way to go. scalebyte could expand the conditionals, but that would get really long (ie, if a== b || a == c || a == d)
<eddie_>
yes
<eddie_>
thats not a good looking code
<eddie_>
or or or and or
Rishi_ has joined #ruby
<scalebyte>
eddie_: worked perfectly thanks :)
<eddie_>
welcome
<philcrissman|afk>
eddie_: yep. include? is ideal for this sort of check.
<scalebyte>
eddie_: i should use include? from now on for such things.. rather than going for ||
<scalebyte>
philcrissman|afk: thanks.. ryt
<philcrissman|afk>
wadkar: does Movie have an attribute named :order_by?
<eddie_>
scalebyte: next time paste your code in a named gist
<wadkar>
philcrissman|afk: nope
<philcrissman|afk>
wadkar: nevermind, read that wrong; it's checking the value of that param.
<wadkar>
philcrissman|afk: yes, and thats why I am wondering, the session is nil, the params is nil, but still
<scalebyte>
eddie_: sure
<wadkar>
(nil as in the hash key doesn't exists so hash['foo'] is nil)
<philcrissman|afk>
wadkar: not totally sure. The line in your debugging session doesn't seem to be the same as any of the lines pasted above.
dhruvasagar has joined #ruby
Morkel has joined #ruby
tk_ has joined #ruby
<philcrissman|afk>
wadkar: also, this might be better asked on #rubyonrails
<eddie_>
scalebyte: Are you placing the value of variable value for :message
<eddie_>
?
<wadkar>
well, if you consider session and params as just another variables available in the scope, it should still make sense right, i mean, the debugger shows that session and params dont have :order_by key, but it still tries and evaluates Movie.attribute_names.include?
<scalebyte>
eddie_: no this is for some different purpose.... live notification
<scalebyte>
eddie_: i am settings values while initialization.. default values... for email and message notification
<eddie_>
scalebyte: i see that when value is true you make :message = true
<eddie_>
and when value = true
<scalebyte>
eddie_: yeah
<eddie_>
Then
<eddie_>
there is another solution
<philcrissman|afk>
wadkar: still doesn't make sense. Where does the line "if Movie.attribute_names.include? params[:order_by]" come from? It isn't in the controller code you pasted.
tatsuya_o has joined #ruby
<eddie_>
would you mind that?
<scalebyte>
eddie_: instead of if value == true i cud just do if value.. ryt !!
<eddie_>
scalebyte: Yes also some more addition
<eddie_>
using a case thing
<eddie_>
i will give you a pastie
nopolitica has joined #ruby
<wadkar>
philcrissman|afk: erm, do I need to restart the webrick server if I change the controller ?
<Stefunel>
guys, how can I see all the methods of a certain object? .methods doesn't list anything
<eddie_>
:)
<eddie_>
Stefunel: is it a custom class?
<wadkar>
strange (or maybe I am dumb) I restarted the webrick server, and now its working fine (apparently)
<Stefunel>
eddie_ yes
<scalebyte>
eddie_: this is nice.. but there are many cases where am assigning same values for multiple attributes.. so i guess include? will b more better ryt?
maasha has joined #ruby
<eddie_>
Stefunel: will get back to you
<maasha>
does ruby have some clever ways to report memory usage of data structures?
<Stefunel>
ok eddie_ thanks
emocakes has joined #ruby
malkomalko has joined #ruby
<eddie_>
Stefunel: Check if you have done it right
<eddie_>
Stefunel: I am getting it. Check the pastie
jjp has joined #ruby
<Stefunel>
thanks eddie_
<Stefunel>
it works
burns180_ has joined #ruby
<wadkar>
thanks philcrissman|afk , your keen eye on the line number solved this problem that I had for so long
<eddie_>
philcrissman: Dude can i use you as a debugger?
<eddie_>
i am too bad in it
<eddie_>
and pron to those
sacarlson has joined #ruby
<wadkar>
eddie_: hehe
<eddie_>
wadkar: "foobar" is still my ancient way of debugging
chimkan__ has joined #ruby
<wadkar>
eddie_: me too, but I want to learn more about debugging, so I tried it out
sacarlson has joined #ruby
<scalebyte>
eddie_: objects.methods to list all methods... it was enlightning ;)
<banistergalaxy>
wadkar: you can use pry as a debugger
darthdeus has joined #ruby
<wadkar>
banistergalaxy: huh? how can it capture the rails server's interrupts?
nanderoo has joined #ruby
<banistergalaxy>
wadkar: ? since when has that been the definition of a debugger? im ot saying it cant do that, but a 'debugger' is simply a tool that can examine callstack, advance execution a line at a time and enable inspection of runtime state.
<wadkar>
banistergalaxy: hmm, so if I can find a way to trigger the rails server from within pyr ... aha! command mode?
<wadkar>
nah, I need to get pry in the RoR mode
<banistergalaxy>
wadkar: no, just put 'binding.pry' where you currently have 'debugger'
<banistergalaxy>
wadkar: read the documentation & watch the screencast :)
visof has joined #ruby
<wadkar>
banistergalaxy: ohh, well I didn't watch the screencast (in office), and just skimmed through basics
<philcrissman|afk>
wadkar: np. You always need to look, the debugger will tell you what line it is on. Glad it helped. :)
M- has joined #ruby
<wadkar>
banistergalaxy: thanks, that should give all pry screencasts at one go (*bookmarks the link*)
flippingbits has joined #ruby
kevinbond has joined #ruby
kevinbond_ has joined #ruby
IAD has joined #ruby
visof has joined #ruby
albemuth has joined #ruby
`brendan has joined #ruby
<Azure>
Hm. Lets say that I want to write a way to grab QDB entries from several websites (with selectors.) What would be a good way to go about writing such a facility?
lateau has joined #ruby
<Azure>
QDB Base (with attributes, etc. for storing rating, url, quote, etc.) -> QDB class (for instance, QDB::Bash) (for parsing the page and storing the results) -> whatever class that I use the single QDB classes in?
nikhil_ has joined #ruby
burns180 has joined #ruby
neurodrone has joined #ruby
n1x has joined #ruby
<Sp4rKy>
/W 4
nopolitica has joined #ruby
fearoffish has joined #ruby
Richmond has joined #ruby
tingo has joined #ruby
jrist has joined #ruby
arvidkahl has joined #ruby
tommyvyo has joined #ruby
burns180_ has joined #ruby
pastjean has joined #ruby
mklappstuhl has joined #ruby
alem0lars has joined #ruby
virgil_ has joined #ruby
john2x has joined #ruby
<virgil_>
hi, I am new to ruby and I have one question
<virgil_>
I have a function aaa?(string) and I also want to be able to write "string".aaa?
moemen has joined #ruby
<virgil_>
I overwrite String class and define the method but I don;t know how to call the function with the same name from outside the class in the class
LMolr has joined #ruby
<virgil_>
:)
<philcrissman>
virgil_: you should just put the method inside the class, if that's what you want to do.
<philcrissman>
or put it in a module, and include the module inside String
<virgil_>
but I also want it outside the class
<virgil_>
how do I do that?
<philcrissman>
virgil_: then I'd put it in a module.
<philcrissman>
A_D search the page for rb_scan_args
nikhgupta has joined #ruby
<A_D>
let me see
<philcrissman>
A_D: I've never used it. :) So I'm not really any more help than that.
nikhgupta has quit [#ruby]
ukwiz has joined #ruby
EvanR has joined #ruby
<A_D>
philcrissman: thanks! Thats what I'm looking for
<philcrissman>
A_D: :D
trivol has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
EddieS has joined #ruby
nelsonblaha has joined #ruby
ceej has joined #ruby
thecreators has joined #ruby
ank has joined #ruby
<nelsonblaha>
anyone mind helping a new rubyist? I guess I don't understand file access yet. This line is causing a file not found: if oldlog != (newlog = File.read(watch))
Sailias_ has joined #ruby
<nelsonblaha>
I've tried making watch equal to the filename (same folder) and the absolute filepath, no luck with either
thecreators has quit [#ruby]
<poseid>
also not much experience with rb_scan_args
<poseid>
but aren't there projects/gems in github where there are examples?
<poseid>
libxml ...
neurodrone has joined #ruby
<canton7>
nelsonblaha, what are you trying to do? Compare the contents of two files?
<nelsonblaha>
canton7, yes
luxurymode has joined #ruby
thecreators has joined #ruby
<A_D>
libxml, pg ....
twqla has joined #ruby
looopy has joined #ruby
ryannielson has joined #ruby
<canton7>
nelsonblaha, there's FileUtils.compare_file if you want to do the comparison without reading the entire file into memory. As for why your example's failing? Not sure. Are you absolutely sure that the contents of oldlog are correctg?
burns180 has joined #ruby
macmartine has joined #ruby
theRoUS has joined #ruby
<nelsonblaha>
canton7, thanks for the tip. oldlog starts out empty on the first loop. is that no good?
<canton7>
nelsonblaha, do you ever write to oldlog?
<canton7>
nelsonblaha, might the problem be that you're opening changelog.txt in mode 'w'?
<canton7>
instead of 'a'
<nelsonblaha>
canton7, I'll give it a shot
<canton7>
since re-opening it with mode 'w' will overwrite whatever's in it
DrShoggoth has joined #ruby
syamajala has joined #ruby
OpenJuicer has joined #ruby
<nelsonblaha>
canton7, it's not even getting to the changelog part though. It's complaining that it can't find the file watch
<nelsonblaha>
canton7, I give it a plaintext file called watchme when I run it. It says watchme: no file or directory
<nelsonblaha>
test.rb:13:in `read': No such file or directory - watchme (Errno::ENOENT)
wmoxam has joined #ruby
<nelsonblaha>
canton7, I created watchme with touch watchme but left it empty
<canton7>
nelsonblaha, aha. What directly is the script running in? Print out Dir.pwd and Dir['*']
Drewch has joined #ruby
tatsuya_o has joined #ruby
<nelsonblaha>
canton7, is that a command I should run in my linux shell or in the ruby script?
<canton7>
nelsonblaha, in the ruby script, at the top
fbernier has joined #ruby
Squarepy has joined #ruby
sdeobald has joined #ruby
<nelsonblaha>
canton7, I get /home/nelson/rubytest.rbwatchmewhat file should I watch?
<canton7>
nelsonblaha, I didn't catch that. 1. Where is the script running? 2. Where is the file located? 3. What are you passing to File.open?
caiges has joined #ruby
jgarvey has joined #ruby
<nelsonblaha>
canton7, script is running in /home/nelson/ruby/
<nelsonblaha>
canton7, file is located in the same directory
<nelsonblaha>
canton7, the string I'm passing to File.open is watchme
<nelsonblaha>
"watchme"
dbgster has joined #ruby
<canton7>
nelsonblaha, are you passing "watchme" or "watchme\n"?
<nelsonblaha>
aha
<nelsonblaha>
I need to strip it
<nelsonblaha>
right?
<canton7>
nelsonblaha, I should have spotted this earler. Line 2 should be watch = gets.chomp
<canton7>
*earlier
trivol has joined #ruby
snip_it has joined #ruby
<nelsonblaha>
canton7, thanks, this has been extremely educational. Probably a common mistake for java programmers. I have different errors to try in google now
axl_ has joined #ruby
renanoronfle has joined #ruby
iamjarvo has joined #ruby
<canton7>
nelsonblaha, haha, no worries. Some languages do the chomping for you; some don't
bbttxu has joined #ruby
<shevy>
java chomps by default?
<shevy>
hmm is .strip calling .chomp actually?
lateau has joined #ruby
davidpk has joined #ruby
wadkar has quit ["Leaving"]
phantasm66 has joined #ruby
<Tasser>
shouldn't
Nathandim has joined #ruby
sbanwart has joined #ruby
heftig has joined #ruby
mklappst_ has joined #ruby
adambeynon has joined #ruby
emmanuelux has joined #ruby
burns180_ has joined #ruby
kpshek has joined #ruby
zul_ has joined #ruby
res0nat0r has joined #ruby
res0nat0r has joined #ruby
Helius has joined #ruby
rippa has joined #ruby
artm has joined #ruby
dv310p3r has joined #ruby
Squarepy has joined #ruby
flippingbits has joined #ruby
idoru has joined #ruby
mikepack has joined #ruby
ElitestFX has joined #ruby
k_89_ has joined #ruby
fayimora has joined #ruby
phreax has joined #ruby
CheeToS has joined #ruby
<phreax>
\join #redmine
baroquebobcat has joined #ruby
<phreax>
uups
ckrailo has joined #ruby
zakwilson has joined #ruby
CheeToS has joined #ruby
elliot_ has joined #ruby
mengu has joined #ruby
startling has joined #ruby
startling has quit [#ruby]
nachtwandler has joined #ruby
lectrick has joined #ruby
CheeToS has joined #ruby
pen has joined #ruby
zeninfinity has joined #ruby
byped has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
PaciFisT has joined #ruby
coreydaley has joined #ruby
CheeToS has joined #ruby
raluxgaza has joined #ruby
Phrogz has joined #ruby
albemuth has joined #ruby
Indian has joined #ruby
<JonnieCache>
whats the command to check a .gemspec file is valid
<JonnieCache>
?
burns180 has joined #ruby
yann_ck has joined #ruby
eywu has joined #ruby
CheeToS has joined #ruby
metakungfu has joined #ruby
metakungfu has quit [#ruby]
artOfWar has joined #ruby
vmatiyko has joined #ruby
trivol_ has joined #ruby
CheeToS has joined #ruby
foxdie has joined #ruby
<foxdie>
Hooray, it exists :)
<foxdie>
Hi all, quick ruby question if I may, to provide backward compatibility to some changes I'm making to a ruby application, is there a way to execute a command and ignore warnings about redefining constants?
scalebyte has joined #ruby
blueadept has joined #ruby
<scalebyte>
I have this for validating special characters presence
<scalebyte>
but hw can I inculde numbers also in this?
<scalebyte>
/^[A-Za-z0-9.&]*\z/
thecreators has joined #ruby
artOfWar has joined #ruby
CheeToS has joined #ruby
dhruvasagar has joined #ruby
alex__c2022 has joined #ruby
asobrasil has joined #ruby
ron has joined #ruby
ph^ has joined #ruby
<scalebyte>
is this called a regular expression? /^[A-Za-z0-9.&]*\z/
<ron>
Maybe someone could assist. Java has a nice little application called Sonar (http://www.sonarsource.org/) to help reduce technical debt. Is there anything similar for Ruby?
chimkan has joined #ruby
<foxdie>
scalebyte: Yep that looks like a regular expression
<scalebyte>
foxdie: thanks... what essentially defines a regex ? in short if you could throw some light !!
<foxdie>
Although by the looks of it, it might be matching every character, the . can match any character, it might need escaping with a backslash
<scalebyte>
shevy: not all are prodigies like you :)
sdeobald_ has joined #ruby
zeninfinity has joined #ruby
<scalebyte>
shevy: tum toh mast ho ruby mein
francisfish has joined #ruby
OpenJuicer has joined #ruby
<phreax>
shevy: yeah this kinda sucks, but i dont see any other way
dr_bob has quit [#ruby]
<phreax>
any suggestions?
t0mmyvyo has joined #ruby
roolo has joined #ruby
<scalebyte>
phreax: where r u from ?
<phreax>
actually i just need to extend class methods of a class (while still have access to the old method)
robacarp has joined #ruby
thecreators has joined #ruby
<phreax>
it works though for me, using alias_method. making it even more complicated
hobodave has joined #ruby
<mneorr>
Hi all, I have one question regarding the @variable ||= something_true in a method. If something_true isn't just a variable, or a method call, is there a way to pass in the block?
Avanine has joined #ruby
amscotti has joined #ruby
<shevy>
scalebyte what does this have to do with prodigies? people use overcomplicated code and then are wondering why things don't work
<shevy>
in ancient times people liked simplicity
<shevy>
then came the agile everything and then the metamagic wave
nvez has joined #ruby
nvez has joined #ruby
<shevy>
soon enough there will be the hipster wave and there will be pink unicorns hidden in ruby code
<Phrogz>
Or "falsey", as they say in JavaScript, meaning that !obj == true
<Eiam>
Mon_Ouie: hmm.. a="something"; a||=[];
<Eiam>
a is "something" still
<philcrissman|afk>
Eiam: that's because a has a value; "something"
<Eiam>
thats interesting that the reverse case is differnt
<mneorr>
okay, got that one. but what happens if the right side of assigment isn't just a variable?
<Eiam>
hmm
<mneorr>
I can paste a snippet
axl_ has joined #ruby
<philcrissman|afk>
Eiam: it shouldn't be. a = []; a ||= "something"; a == []
<mneorr>
for now, I've just called a new method; But for the learning purposes of the syntax, thought there might be a way to do it inline
<mneorr>
def array
<mneorr>
@array ||= initialize_array
<mneorr>
end
<mneorr>
def initialize_array
<mneorr>
array = []
<mneorr>
1.upto(234) do |numbah|
<mneorr>
array << numbah
<mneorr>
end
<mneorr>
<mneorr>
array
<mneorr>
end
<Eiam>
philcrissman|afk: thats the same case you posted initially
<shevy>
lol
<shevy>
|numbah|
<philcrissman|afk>
Eiam: yes, it is.
<shevy>
best name ever :)
<philcrissman|afk>
Eiam: and the same result.
<mneorr>
yeah, picked it up from one guy I've used to pair program in the US :D
<mneorr>
*program with
<Eiam>
=/ I just use x & i
<Eiam>
<< not very creative
Targen has joined #ruby
dr_bob has quit [#ruby]
greenarrow has joined #ruby
<shevy>
being too clever is annoying
<Eiam>
philcrissman|afk: okay so to rephrase again then.. a ||= value assigns value if a is nil and value is not nil
<shevy>
like that roman class that implements roman numbers via method_missing
<Phrogz>
mneorr: Next time, please use pastie.org or another paste service.
<mneorr>
okay sure, I'm a newbie here
<Phrogz>
mneorr: @array ||= (1..234).to_a
apok has joined #ruby
theRoUS has joined #ruby
theRoUS has joined #ruby
<mneorr>
:D I knew someone will make an inliner for it. this is awesome
<Phrogz>
mneorr: Or in general: @array ||= [].tap{ |a| .. do mutating things with a here ... }
dnyy has joined #ruby
<mneorr>
okay, got this one with the block passed in,. that was more a question
<mneorr>
like, is there any other way to do a multiline as well?
apok has joined #ruby
<mneorr>
e.g. , I've tried to use just @array ||= { some code here } , but obviously that didn't work
<Phrogz>
mneorr: You could convert my tap block to a do/end and multiline it. But if you want to just run arbitrary code, you'd need unless @array ... multiline code here that sets @array ... end
<Phrogz>
And then @array at the end.
<Phrogz>
mneorr: You want a begin/end block to evaluate many lines as the last expression.
<fowl>
why do i get this message about modruby, a dead project
johndbritton has joined #ruby
ringotwo has joined #ruby
alx- has joined #ruby
<wmoxam>
fowl: it throws off the noobs
* wmoxam
is only slightly joking, doesn't see why else it would be there
Draco_ has joined #ruby
<philcrissman|afk>
Eiam: yep
<Eiam>
man thats going to clean up a lot of my code
<Eiam>
i do tons of silly checks like that
<philcrissman|afk>
Eiam: well, technically, I guess it would assign nil to it, as well. Not that there would be a difference; a = nil; a ||= nil; a == nil. ;-)
musl has joined #ruby
havenn has joined #ruby
Sailias has joined #ruby
<philcrissman|afk>
Eiam: though; that would be significant if you wanted it to become explicitly false; a = nil; a ||= false; a == false;
dr_bob1 has joined #ruby
<philcrissman|afk>
Eiam: just play around with that in irb for awhile, you will see exactly how it works.
<philcrissman|afk>
Eiam: well, it sounds like you got it already. But nothing like seeing how it works.
<Eiam>
tap? /me goes to look up
<Eiam>
philcrissman|afk: right but that makes sense, false is not nil
<Eiam>
philcrissman|afk: so I'd expect a ||=false; a == false
seoaqua has joined #ruby
<philcrissman|afk>
Eiam: yep. but remember, if it starts out false, it would be reassingned to something truthy. a = false; a ||= "something"; a == "something"
<philcrissman|afk>
s/reassigned
<seoaqua>
hi guys, which is the right way to iterate a hash when deleting some elements of it? e.g. hash.each_key {|k| hash.delete k}
<Eiam>
ahh okay thats a minor catch but important
<Eiam>
philcrissman|afk: whats the logic behind that assignment? false is not nil, so it seems like it should keep false
<Eiam>
seoaqua: wouldn't that be mutating something while you are iterating it?
<Eiam>
not sure how ruby handles that, but I know objc doesn't like that =)
<Eiam>
crashy crash
shruggar has joined #ruby
<Eiam>
philcrissman|afk: I guess "truthiness" is the logic used there. still seems slightly inconsistent
cbuxton has joined #ruby
<philcrissman|afk>
Eiam: not exactly; nil and false are both "falsey".
panpainter has joined #ruby
zodiak has joined #ruby
<Eiam>
philcrissman|afk: sure, but as pointed out, a ||=false == false, but false ||='something' == 'something'
<seoaqua>
Eiam, im doing like hash_copy = hash; hash_copy.each_key{...}; hash = hash_copy; are there any better ways
facefox has joined #ruby
<philcrissman|afk>
Eiam: so, in most cases, it's seeing if a is "truthy", and if not, assigning whatever to it. In the case of nil and false, it just so happens that "false" is a little better defined than nil; so a nil ||= false would become explicitly false.
musl has joined #ruby
<philcrissman|afk>
Eiam: exactly.
<seoaqua>
Eiam, sorry not a correct example
zul has joined #ruby
<Eiam>
philcrissman|afk: right. I follow
dr_bob1 has quit [#ruby]
<Eiam>
nil and false are the same except when you are comparing them directly
<Eiam>
for purposes of ||=
gianlucadv has joined #ruby
<Mon_Ouie>
seoaqua: #delete_if?
<Mon_Ouie>
Also do you realize hash_copy isn't a copy of the hash?
fowl has joined #ruby
<philcrissman|afk>
Eiam: mmm more or less, sure. As far as the truth value goes.
<deryldoucette>
Mon_Ouie: oo i didn't know that myself
schovi has joined #ruby
<seoaqua>
Mon_Ouie, yes,maybe, i'll look into it, thanks~
<Eiam>
seoaqua: also, did you try what you posted, cause that worked fine for me
<deryldoucette>
building my docs now, so will look that up when it completes
<Mon_Ouie>
When you do var_a = var_b you're making var_a reference the same object as var_b
<philcrissman|afk>
Eiam: I'd stop short of saying that nil and false are the same.... they're each their own class. nil.class == NilClass; false.class == FalseClass
<canton7>
fowl, oops, missed that. updated the pastie
linoj_ has joined #ruby
PragCypher has joined #ruby
<Phrogz>
Or duration_array = (1..8).map{ |i| pluralize(i, 'hour') }.zip(1..8) :)
sahli_ has joined #ruby
* Phrogz
loves Array#product and Array#zip
wroathe has joined #ruby
<Phrogz>
ericdfields: BTW, what are you using this datastructur for? Smells...wrong.
rexbutler has joined #ruby
Targen has joined #ruby
<Phrogz>
I'm still surprised how the presence or absence of a single character can transform an otherwise-good sentence into something that appears to come from a 12 y/o fool.
chsonnu has joined #ruby
<deryldoucette>
lol
banister_ has joined #ruby
Foxandxss has joined #ruby
sbabiy_ has joined #ruby
kylemcgill has joined #ruby
srid has joined #ruby
srid has joined #ruby
srid has joined #ruby
zakwilson has joined #ruby
axl_ has joined #ruby
pastjean has joined #ruby
Vadim2 has joined #ruby
workmad3 has joined #ruby
ryannielson has joined #ruby
AxonetBE has joined #ruby
undersc0re has joined #ruby
undersc0re has joined #ruby
joshmbrown has joined #ruby
artm has joined #ruby
igaiga has joined #ruby
blackflys has joined #ruby
blackflys has quit [#ruby]
trivol_ has joined #ruby
blackflys has joined #ruby
squidz has joined #ruby
virunga has joined #ruby
FACEFOX has joined #ruby
<squidz>
I tried to run a block in ruby every 194 times by using the modulo condiational if(index%194 ==1) then run block, but it doesnt seem to do it every 194 times
<squidz>
any idea why?
albemuth has joined #ruby
PragCypher has joined #ruby
visof has joined #ruby
visof has joined #ruby
<squidz>
could it be that ruby is rounding the division result?
<burgestrand>
squidz: 5.5 % 5 # => 0.5
<burgestrand>
so, no rounding
<burgestrand>
but floats can be scary to deal with at times
<fowl>
squidz: 1000.times { |x| next unless x % 194 == 0; p x } #=> 0, 194, 388, etc
<fowl>
i dunno if thats what you need but you can use something like that in irb to model the results
<Phrogz>
squidz: On the face of it what you're doing works fine.
<squidz>
fowl: it looks like that might well be what I am trying ill look into it, thanks
* Phrogz
ponders what makes 194 special
phantasm66 has joined #ruby
<Phrogz>
194.prime_division #=> [[2, 1], [97, 1]]
MrGando has joined #ruby
<shadoi>
wow, there are a lot of "facts" associated with 194.
<squidz>
Phrogz: I am trying to scrape a 974 links, which should be no problem except that I seem to time out becaues of excessive traffic so I want to break those 947 page visits up with a sleep every now and then. I though 194 divides 974 evenly but it looks like that was a mistake. Maybe I am approaching this wrongly
booginga has joined #ruby
<robacarp>
o-O
<shadoi>
hehe
<Phrogz>
Oo indeed
spox has joined #ruby
<Phrogz>
squidz: Why not just a) put a small sleep after each fetch, and b) rescue the timeouts and handle them appropriatel?
<shadoi>
better yet, spawn a thread for #-cores at a time, and let them finish before spawning new threads.
<robacarp>
"This is an incomplete list"
<shadoi>
hahha
<Phrogz>
And no, c) 974.prime_division #=> [[2, 1], [487, 1]]
Banistergalaxy has joined #ruby
<squidz>
rescuing the timeouts looks like a nice solution but i'm not sure that sleeping after each call with prevent my problem
<shadoi>
wikipedia is so FAIL, they can't even list all numbers!
<squidz>
damn you 974
ph^ has joined #ruby
<robacarp>
you don't need to divide you request blocks evenly to make it happen
<robacarp>
just make it sleep every 100 or so.
<robacarp>
the last block will only be 74...so what...
<squidz>
robacarp: yeah I thought about that too, but I think just rescuing with a timeout would be more efficient
mmokrysz has joined #ruby
<squidz>
preventing unneeded sleeps
mmokrysz has quit [#ruby]
<squidz>
but this is the first time ive done anything with error/exception handling with ruby, since it is only my second thing ive done in ruby
<squidz>
but so far i'm really diggin it
<shadoi>
squidz: did you look at Scrubyt and Mechanize?
<robacarp>
I mean...the reality of the problem is that you are being rate-limited by the server, which is inherently a chronographic problem. Implementing chronographic delay solutions to a chonographic problem seems reasonable to me.
<robacarp>
but, now that I think about it....I agree with you...
<robacarp>
rescue a timeoutt, then sleep.
doublethink has joined #ruby
<robacarp>
/but/ that might not be the fastest way to scrape all the links. If you stay within the bounds you don't need to wait for the timeout.
tomzx has joined #ruby
<robacarp>
I suppose it depends on how long the timeout takes compared to how long you'd need to sleep between requests.
lep-delete has quit [#ruby]
iocor has joined #ruby
wilmoore has joined #ruby
bglusman has joined #ruby
<squidz>
robacarp: true
<robacarp>
MATH!
<squidz>
thanks for the help and advice guys, the ruby community seems pretty friendly. Yall make it a good experience
alaa_ has joined #ruby
wallerdev has joined #ruby
<booginga>
hey all this is more a rails question but the guys in #RubyOnRails are talking about hair cuts :) Anyone know why something like this would be giving me a routing error format.html { render 'admin/users/show', :layout => true }
<booginga>
but this format.html { render 'admin/users/index', :layout => true } works fine? Im trying to render a partial from another controller that lives in the namespace admin
<alaa_>
Hello guys, I need to build my final project using Sinatra and MongoDB, but I need to learn Ruby first, I have good exeprince with PHP, JAVA, OOP, and design patters. Would you give some resrouces to learn the latest ruby. thank you.
<gogiel>
alaa_: Eloquent Ruby book
pingfloyd has joined #ruby
Vadim has joined #ruby
<alaa_>
gogiel: thank you
bwlang has joined #ruby
<squidz>
shadoi: yeah I am using mechanize
<gogiel>
alaa_: this is my favourite. you can read any book/tutorial and go deeper with google
<squidz>
shadoi: it's handy as hell
<undersc0re>
booginga: Ask in #RubyOnRails anyways
libertyprime has joined #ruby
<undersc0re>
i dunno why so many people come here for rails questions ._.
libertyp1ime has joined #ruby
pablo__ has joined #ruby
<doublethink>
undersc0re, because they think that ruby is rails
<undersc0re>
RoR should change it's name to Rails on Ruby
<undersc0re>
Because Ruby doesn't ride on Rails
<fowl>
thankfully
<philcrissman|afk>
booginga: if you stop and think about your routes you'll see the answer. Ask in #rubyonrails, I'll tell you. :)
asobrasil has quit [#ruby]
<philcrissman|afk>
ah heck. I guess I can tell you here. But; think about the show route. How's it different from an index route?
<booginga>
needs an id
<philcrissman|afk>
and what did you not give it?
albemuth has joined #ruby
<philcrissman|afk>
sorry, just saw that you did ask in ROR. Maybe someone will answer it there, too. :)
<booginga>
thats weird though because i can pass admin/users/edit
<booginga>
and its fine
<booginga>
how should i pass it it
<philcrissman|afk>
booginga: ...
<booginga>
:id => @user.id
<doublethink>
params[:id]?
<philcrissman|afk>
actually edit should not work without an id either. That's interesting. Would have to see your routes to know why.
<philcrissman|afk>
booginga: see #ror, answering now
adit has joined #ruby
<booginga>
i would its invite only i think
<philcrissman|afk>
booginga: nonsense. you've already asked several questions.
<booginga>
oh sorry thought you were actually saying #ror
<philcrissman|afk>
booginga: #ror is just shorthand for #rubyonrails. if there's an actual #ror channel, I've never bothered with it.
<philcrissman|afk>
booginga: no, I see how you could think that, sorry. less typing. :)
tatsuya_o has joined #ruby
jbhewitt has joined #ruby
<undersc0re>
philcrissman|afk, booginga: #ror redirects to #RubyOnRails
<philcrissman|afk>
undersc0re: aha. Well, there you are.
<philcrissman|afk>
undersc0re: hm. Actually, for me, it does say "cannot join channel, must be invited" (#ror)
<undersc0re>
uh
tommyvyo has joined #ruby
<bingomanatee_>
For some reason my metal class is not kicking in - is there something you have to do to disable/enable the "metal" directory in a 3.0 app?
sungji has joined #ruby
sungji has joined #ruby
Boohbah has joined #ruby
<apeiros_>
bingomanatee_: #rubyonrails
<bingomanatee_>
thx
<sungji>
Hi! I'd like to add a function to "enumerables", e.g. [54,692,830, 3240].great? However, apparently, Enumerable isn't a class :/ so how can I add a function to enumerables?
<fowl>
sungji: Enumerable is a module
coreydaley has joined #ruby
dagnachewa has joined #ruby
carlyle has joined #ruby
<fowl>
module Enumerable; stuff; end
<sungji>
fowl, oh, I see
<burgestrand>
won’t work for objects that have already included/extended Enumerable
<apeiros_>
sungji: you may be looking for the already existing method `max`
<fowl>
apeiros_: can i suggest taking the modruby.net link out of the channel greeting and replacing it with something about rails having separate channel
apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
<apeiros_>
I should probably put the rails part to the front…
tayy has joined #ruby
mxbtty has joined #ruby
<apeiros_>
fowl: oh, channel greeting is done by chanserv
<apeiros_>
can't change that…
<fowl>
apeiros_: i meant the chanserv greeting you get when you join
<fowl>
ah
<apeiros_>
I'm trying to get fflush to change ownership of the channel or at least give me more power for years now… I don't think it'll ever happen.
<undersc0re>
-Notice- {from ChanServ} Registered : Feb 05 15:20:56 2003 (9 years, 5 weeks, 3 days, 07:56:50 ago)
<undersc0re>
apeiros_: wow
<apeiros_>
undersc0re: now do /ns info fflush
<apeiros_>
pay attention to the 'last seen'
<undersc0re>
apeiros_: :|
wallerdev has joined #ruby
<apeiros_>
undersc0re: yeah, that's my face. except - 2 years ago
<apeiros_>
now it's just =(
<undersc0re>
apeiros_: you may be able to convince freenode staff to transfer ownership
<apeiros_>
no
<apeiros_>
I asked a bit around
<apeiros_>
not a way I can go
<apeiros_>
neither #ruby nor #ruby-lang is an official channel, they actually already violate freenode policy
<apeiros_>
(#ruby-lang is at least half-way official by being acknowledged on ruby-lang.org)
<undersc0re>
Wow.. I'm surprised they haven't shut this place down
<apeiros_>
I'm not
<apeiros_>
I've started the process to get my hostmask about 5y ago
<apeiros_>
it should have taken a week or something
<apeiros_>
I still don't have it
<undersc0re>
o_O
<apeiros_>
not surprised by a bit that stuff like shutting down a channel doesn't happen in the blink of an eye…
manizzle has joined #ruby
smgt has joined #ruby
pu22l3r has joined #ruby
GSpotAssassin has joined #ruby
Banistergalaxy has joined #ruby
havenn has joined #ruby
tomzx has joined #ruby
MasterBob has joined #ruby
MasterBob has joined #ruby
y3llow has joined #ruby
bondar has joined #ruby
<bpgoldsb>
If I have a class (foo) inside another class (bar), how do I access the baz method of bar from insize foo?
bwlang has joined #ruby
mxbtty has quit [#ruby]
<apeiros_>
bpgoldsb: the nesting of classes doesn't change anything about accessibility
mengu has joined #ruby
S0lign0c has joined #ruby
<apeiros_>
also, for the sake of clarity, capitalize your classnames in your questions…
<bpgoldsb>
apeiros_: Well, inside bar, I can call notice. When I try to call it from within foo, I get undefined method.
<fowl>
bar::foo.baz ?
<bpgoldsb>
Admittedly, I'm new to ruby, so it could be another issue. But I'm having problems tracking it
leoncamel has joined #ruby
gokul has joined #ruby
iocor has joined #ruby
<apeiros_>
bpgoldsb: yes, because methods of Foo have nothing to do with methods of Foo::Bar
<fowl>
nm, i didnt read it right
<apeiros_>
the two classes are unrelated
jbw_ has joined #ruby
_null has joined #ruby
<apeiros_>
it's no different than if you had a class Foo and a class Bar, without Bar beint nested in Foo.
<frontendloader>
line 45, trying to bitwise and on a string
<frontendloader>
(digest[digest[19] & 0x0F, 4]
<apeiros_>
frontendloader: any reason to use a pastebin with ads?
<robacarp>
gist!
<frontendloader>
how will you ever survive!
<fowl>
lol
nik_-_ has joined #ruby
<fowl>
not sure what a bitwise & is supposed to do to a string
macmartine has joined #ruby
<robacarp>
this is some gnarly code
<frontendloader>
that code /should/ work in 1.8.7
<apeiros_>
frontendloader: if you'd have given the actual error, you could have gotten a quicker answer
<apeiros_>
String#[index] used to return an int
<apeiros_>
it doesn't anymore
<frontendloader>
thanks for the answer without the snark
<apeiros_>
use unpack or String#ord
<apeiros_>
frontendloader: I can easily give you a boot too…
<frontendloader>
you reap what you sow man, was I snarky to you at the outset?
<fowl>
everybody calm down and drink appletinis with me
<apeiros_>
frontendloader: I have not much left for people who make half-assed questions, and fail to provide proper info even when explicitly asked for it.
M- has joined #ruby
pingfloyd has joined #ruby
havenn has joined #ruby
Targen has joined #ruby
_2easy has joined #ruby
mikeric has joined #ruby
wroathe has joined #ruby
<frontendloader>
getbyte/byteslice are the new methods for that then?
<robacarp>
ord
<robacarp>
string.ord(5)
<robacarp>
er
<robacarp>
string[5].ord
<frontendloader>
ord's for chars I think
IrishGringo has joined #ruby
<robacarp>
that syntax works under both 1.8 and 1.9 rubies, iirc
shevy has joined #ruby
workmad3 has joined #ruby
<td123>
so
<apeiros_>
it doesn't work pre 1.8.7
<td123>
does ruby keep a copy of past ruby releases as a .bz2? it seems ruby 1.9.3p125 has done a silent release and only updated the md5sum on the pkg