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/
pu22l3r_ has joined #ruby
jxpx777 has joined #ruby
rmacd has quit [#ruby]
gen0cide_ has joined #ruby
pac1 has joined #ruby
cassarani has joined #ruby
apok_ has joined #ruby
bwlang has joined #ruby
<voodoofish430>
question related to class vars, I have ot actually right a method to access these, I cant use attr_reader :classvarname, correct?
<voodoofish430>
write a method
<voodoofish430>
...ignore that right...
<havenn>
virtuoussin13: Class A; end; A.new.foo(1,2,3) { |a,b,c| a + b + c }; A.send(:define_method, :foo) { |a, b, c, &block| a + b + c } #=> 6
Nisstyre has joined #ruby
albemuth has joined #ruby
<Maarius>
oooPaul: wow, it works. Thank you so much!
<cassarani>
voodoofish430: technically you could use attr_reader, but only if you class_eval it
<cassarani>
(presumably)
<havenn>
virtuoussin13: Looks like you just needed the &block on your #foo.
<virtuoussin13>
havenn: I don't see yield in there tho
<cassarani>
voodoofish430: but I could be wrong, class variables are confusing as hell
<voodoofish430>
hmmmm...I'll just stick with a method then.
<cassarani>
yeah, I don't think you can do that actually
<cassarani>
I think my answer would be "do you _really_ need a class variable? ;)"
<cassarani>
Rubyists kinda tend to frown upon them
banisterfiend has joined #ruby
<virtuoussin13>
this still doesn't work A.send(:define_method, :foo) { |a,b,c,&blk| yield(a,b,c) }; puts A.new.foo(1,2,3) { |a,b,c| a + b + c }
<havenn>
virtuoussin13: oops I failed with the yield, sec
_obiJuan has joined #ruby
<voodoofish430>
really, they do?
<voodoofish430>
class vars for tracking things at could be related to multiple intsances?
<cassarani>
why can't you just use an instance variable on the class?
<cassarani>
class variables have very odd behaviour when inheritance is introduced
<banisterfiend>
virtuoussin13: is that yield supposed to call that &blk ?
<virtuoussin13>
banisterfiend: yes
<shadoi>
cassarani: what's odd about it staying the same?
<banisterfiend>
virtuoussin13: use blk.call instead
t0mmyvyo has joined #ruby
<banisterfiend>
the 'yield' always refers to the enclosing scope
<banisterfiend>
so you'll likely yield to the wrong block or just get an error ;)
<cassarani>
shadoi: I think class variables are shared across the whole class hierarchy
<cassarani>
shadoi: so (if I remember correctly) subclasses can modify a superclass' value of a class variable
<cassarani>
or something along those lines
<shadoi>
cassarani: yeah, I suppose it's not obvious you can shoot yourself in the foot with it.
CannedCorn has joined #ruby
tatsuya_o has joined #ruby
<shadoi>
sort of like a scoped global.
<oooPaul>
back.
<oooPaul>
I think banisterfiend has the right idea.
<virtuoussin13>
what does scope have to do with yield tho?
evenix has joined #ruby
<evenix>
hi all
trend has joined #ruby
<voodoofish430>
cassarani: that article is around 5 years old.....and from looking at the comments, later versions of ruby act differently from the one that was used in this example.
<cassarani>
shadoi: yeah, I think the main problem is that the order that your classes or subclasses get loaded in will affect what value a class variable will have
<banisterfiend>
virtuoussin13: because the block is a closure, it doesnt just close over local variables it also closes over any extant blocks
<cassarani>
which is bloody sneaky
<banisterfiend>
virtuoussin13: i wrote a blog about it holdon
<cassarani>
voodoofish430: you're probably right, I just gave you the first google search result for what I was really getting at
<oooPaul>
Yeah, that works.
<shadoi>
cassarani: I use it in 1 place as a connection cache, for that it's good, but there are very few cases I'd ever use it otherwise.
<oooPaul>
define_method(:foo) do | a, b, c, &blk|; blk.call(a, b, c); end
<cassarani>
voodoofish430: the main problem with class variables is - as I said above - that they tend to lead to bugs that are very difficult to debug because of the way they are shared across the class hierarchy
<cassarani>
shadoi: exactly the same here
replore has joined #ruby
<cassarani>
voodoofish430: either way, it's a well-known fact that experienced Rubyists will tend to shy away from class variables when possible
<voodoofish430>
cassarani: I'm using the class var as it's simple to use for what I need. using instance vars would require more work I would imagine since I have to keep the var count related to each and count them.
<virtuoussin13>
ugh.
<cassarani>
voodoofish430: you can use an instance variable on the class
<cassarani>
voodoofish430: and it will act like a class variable, except sensible
hadees has joined #ruby
<virtuoussin13>
silly silly silly
<virtuoussin13>
okay thanks
<cassarani>
voodoofish430: I know you're unlikely to run into any problems, I'm just telling you what you're doing is kind of a bad practice
<cassarani>
voodoofish430: but I'm sure it works just fine
looopy has joined #ruby
randym has joined #ruby
oddmunds has joined #ruby
Sivart has joined #ruby
Fighterr has joined #ruby
<voodoofish430>
cassarani: it works for what I'm doing, but I'll take a look at another article that mentions the evils of it's uses. Thanks! :D
<voodoofish430>
I think this one may be a bit more up to date.
<cassarani>
the book "Eloquent Ruby" (which is excellent, by the way) has a chapter on the whole issue
dv310p3r has joined #ruby
<Fighterr>
anybody here ?
kmurph79 has joined #ruby
<virtuoussin13>
Fighterr: no
<virtuoussin13>
Fighterr: I'm kidding
<virtuoussin13>
ask away
<Fighterr>
virtuoussing13 : funny ;)
neurodrone has joined #ruby
neurodrone has joined #ruby
brngardner has joined #ruby
trengof has quit [#ruby]
Nisstyre has joined #ruby
al3xnull has joined #ruby
mmokrysz has joined #ruby
mmokrysz has quit [#ruby]
rushed_ has joined #ruby
gift has joined #ruby
havenn has joined #ruby
banisterfiend has joined #ruby
banister_ has joined #ruby
stephenjudkins has joined #ruby
bwlang has joined #ruby
tyfighter has joined #ruby
hubub_ has joined #ruby
_|christian|_ has joined #ruby
eignerchris has joined #ruby
bwlang has joined #ruby
crodas has joined #ruby
nowthatsamatt has quit [#ruby]
saurb has joined #ruby
<ElderFain>
robacarp is a badass. that is all.
nerickson has joined #ruby
mikepack has joined #ruby
luxurymode has joined #ruby
nerickson has quit [#ruby]
IAD has joined #ruby
dyer has joined #ruby
dyer has joined #ruby
dyer has joined #ruby
nari_ has joined #ruby
Dreamer3 has joined #ruby
Indian has joined #ruby
looopy has joined #ruby
kurko_ has joined #ruby
frishi has joined #ruby
salax_ has joined #ruby
wroathe has joined #ruby
dyer has joined #ruby
chessguy has joined #ruby
apok has joined #ruby
wroathe has quit [#ruby]
redgetan has joined #ruby
samsonjs_ has joined #ruby
kmurph79 has joined #ruby
philcrissman_ has joined #ruby
DFectuoso has joined #ruby
hooper_ has joined #ruby
Nathandim has joined #ruby
al3xnull has joined #ruby
Ripp__ has joined #ruby
hadees has joined #ruby
cloke_ has joined #ruby
astrostl has joined #ruby
nowthatsamatt has joined #ruby
mikeycgto has joined #ruby
mikeycgto has joined #ruby
hadees has joined #ruby
josefig has joined #ruby
marknyc has joined #ruby
albemuth has joined #ruby
samsonjs has joined #ruby
havenn has joined #ruby
apok_ has joined #ruby
twoism has joined #ruby
astrostl has quit [#ruby]
bwlang has joined #ruby
SeanTAllen has joined #ruby
dnyy has joined #ruby
seanstickle has joined #ruby
mxweas_ has joined #ruby
yoda_ has joined #ruby
chimkan_ has joined #ruby
<startling>
do any of you use treetop? what's the best way to do "many of this rule, separated by spaces"?
Targen has joined #ruby
bwlang has joined #ruby
oddmunds_ has joined #ruby
jergason has joined #ruby
ReTFEF has joined #ruby
yoda_ has quit [#ruby]
SegFaultAX has joined #ruby
tomzx has joined #ruby
wroathe has joined #ruby
radic_ has joined #ruby
saurb has joined #ruby
rfloriano has joined #ruby
banisterfiend has joined #ruby
luxurymode has joined #ruby
dootdoot has joined #ruby
p0y has joined #ruby
giminy has quit [#ruby]
fayimora_ has joined #ruby
aetaric has joined #ruby
SirFunk has joined #ruby
dagnachewa has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
ZachBeta has joined #ruby
matthias3 has joined #ruby
chimkan has joined #ruby
jbhewitt has joined #ruby
p0y has joined #ruby
c0rn has joined #ruby
kmurph79 has joined #ruby
Banistergalaxy has joined #ruby
ceej has joined #ruby
havenn has joined #ruby
ZachBeta has joined #ruby
havenn has joined #ruby
chimkan has joined #ruby
kp666 has joined #ruby
twock has joined #ruby
kenperkins has joined #ruby
MissionCritical has joined #ruby
chrxn_ has joined #ruby
conntrack has joined #ruby
guns has joined #ruby
sinuc has joined #ruby
sinuc has joined #ruby
conntrack has joined #ruby
rippa has joined #ruby
_obiJuan has joined #ruby
mxweas__ has joined #ruby
mxweas_ has joined #ruby
xjiujiu has joined #ruby
saurb has joined #ruby
pingfloyd has joined #ruby
Liothen_ has joined #ruby
evenix has joined #ruby
jwmann has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
ninor has joined #ruby
samsonjs has joined #ruby
Karmaon has joined #ruby
jergason has joined #ruby
nacengineer has joined #ruby
yfeldblum has joined #ruby
audy has joined #ruby
TheMoonMaster has joined #ruby
TheMoonMaster has joined #ruby
dv310p3r has joined #ruby
lavaman has joined #ruby
affix has joined #ruby
mpereira has joined #ruby
syamajala has joined #ruby
dootdoot has joined #ruby
dturnbull1 has joined #ruby
hubub has joined #ruby
havenn has joined #ruby
gokul has joined #ruby
snip_it has joined #ruby
dv_ has joined #ruby
redgetan has quit ["Leaving"]
hubub has joined #ruby
asteros has joined #ruby
viper1092 has joined #ruby
syamajala has joined #ruby
evenix has quit [#ruby]
hubub has joined #ruby
<asteros>
hey all, is there a way to split a string by a delimiter only when it's not in quotes without resorting to regex? For example, "\"Hello, one\", \"Hello, two\"".split(",") returns each individually
<asteros>
thanks in advance
a_a_g has joined #ruby
sdwrage has joined #ruby
<rippa>
split('",')
jhunter has joined #ruby
<asteros>
ah, ok, thanks. looks like i'll just write up some regex for the split and try to make it robust enough
i8igmac has joined #ruby
ehqhvm has joined #ruby
h4mz1d has joined #ruby
achamian has joined #ruby
bluOxigen has joined #ruby
robbyoconnor has joined #ruby
macmartine has joined #ruby
dturnbull1 has quit [#ruby]
zomgbie has joined #ruby
kmurph79 has joined #ruby
wyhaines has joined #ruby
tensai_cirno has joined #ruby
sixdahs has joined #ruby
ChampS666 has joined #ruby
fallen has joined #ruby
t-mart has joined #ruby
nfluxx has joined #ruby
<t-mart>
what must I do to have an instance method return a new instance of the same class. "return new" comes back with undefined method and self.class.new doesn't work either because i've private_class_method :new
SamAxe has joined #ruby
taipres has joined #ruby
twock has joined #ruby
_obiJuan has joined #ruby
ali_h has joined #ruby
aetaric has joined #ruby
sinuc has joined #ruby
Seisatsu has joined #ruby
fuzai has joined #ruby
adeponte has joined #ruby
c0rn has joined #ruby
Fuzzy has joined #ruby
X99 has joined #ruby
sinuc has joined #ruby
<davidcelis>
you made new private?
elliot_ has joined #ruby
adeponte has joined #ruby
X99 has joined #ruby
<startling>
can I get treetop to throw out certain things, like spaces and parentheses?
pu22l3r has joined #ruby
don9z has joined #ruby
seitensei has joined #ruby
fuzai_ has joined #ruby
Fuzzy_ has joined #ruby
akem has joined #ruby
akem has joined #ruby
don9z has quit ["Killed buffer"]
maletor has joined #ruby
tonini has joined #ruby
ehqhvm has quit [#ruby]
sinuc has joined #ruby
banisterfiend has joined #ruby
lolmaus has joined #ruby
vandemar has joined #ruby
<lolmaus>
Hi! Please suggest a library to parse command line arguments
<banisterfiend>
lolmaus: slop
<lolmaus>
banistergalaxy, thx
<lolmaus>
I've started using Rubymine and Gitgub, but i'm not familiar with either. I'm going to rewrite my 'lil project from scratch. What's the appropriate approach for that in git?
<lolmaus>
Something tells me starting a new repo would be best...
<banistergalaxy>
lolmaus: git init
<lolmaus>
banistergalaxy, i mean i've already got my project into Github. And i'm updating it with Rubymine as i code. But i'm going to rewrite it totally. Should i dump the repo or there's some technique like branching or whatever?
<banistergalaxy>
lolmaus: well, if u want to keep the project structure then branch
don9z has joined #ruby
<banistergalaxy>
lolmaus: but u dont have to branch if you really dont want ot keep your current work, just write it the way u want then push it
<banistergalaxy>
you'll still have what you've got now in your history anyway
<lolmaus>
Thx banistergalaxy
artOfWar has joined #ruby
don9z has quit ["ERC Version 5.3 (IRC client for Emacs)"]
iMe has joined #ruby
GoBin has joined #ruby
sdwrage has joined #ruby
banister_ has joined #ruby
yxhuvud has joined #ruby
chrxn_ has joined #ruby
thone has joined #ruby
_obiJuan has joined #ruby
samsonjs_ has joined #ruby
chimkan_ has joined #ruby
apok has joined #ruby
bryanray has joined #ruby
mxweas_ has joined #ruby
looopy has joined #ruby
manizzle has joined #ruby
kaiwren has joined #ruby
ABK has joined #ruby
Morkel has joined #ruby
dcvii has joined #ruby
punkrawkR has joined #ruby
shellox has joined #ruby
<shellox>
hi
nmkolev has joined #ruby
<shellox>
is there a tool like metrical for ruby 1.9?
CodeZombie has joined #ruby
hmans has joined #ruby
Helius has joined #ruby
twoism has joined #ruby
senny has joined #ruby
headius has joined #ruby
samuel02 has joined #ruby
macmartine has joined #ruby
djdb has joined #ruby
fallen has joined #ruby
vectorshelve has joined #ruby
<vectorshelve>
is there a way i can get rid of a ban from a room...
youdonotexist has joined #ruby
twock has joined #ruby
nemesit has joined #ruby
JohnBat26 has joined #ruby
hmans has joined #ruby
zomgbie has joined #ruby
sarkis has joined #ruby
<sarkis>
hey guys i can't find what ruby -rubygems does in the man pages for ruby
<sarkis>
sintra website says to run sinatra apps like: ruby -rubygems app.rb, i'm assuming that tells ruby to use rubygems?
ChampS666 has joined #ruby
saurb has joined #ruby
trivol has joined #ruby
mafolz has joined #ruby
mxweas_ has joined #ruby
adman65 has joined #ruby
saurb has joined #ruby
<lolmaus>
Anyone familiar with Slop?
zomgbie has joined #ruby
Azure|netbook has joined #ruby
Azure has joined #ruby
krz has joined #ruby
mrtheshadow has joined #ruby
djdb has joined #ruby
bier has joined #ruby
Sliker has joined #ruby
adeponte has joined #ruby
Spockz has joined #ruby
bertho_y has joined #ruby
ilyam has joined #ruby
saurb has joined #ruby
sdwrage has joined #ruby
ChampS666 has joined #ruby
twoism_ has joined #ruby
JStoker has joined #ruby
telling has joined #ruby
twoism has joined #ruby
twqla has joined #ruby
InBar has joined #ruby
twoism has joined #ruby
marvin_ has joined #ruby
pi3r has joined #ruby
Mekkis has joined #ruby
<vectorshelve>
hala
<vectorshelve>
is there way a user can get out of a ban from a room particluar ?
<vectorshelve>
ABK: if a user is banned from a room hw can he get back in?
<GoBin>
vectorshelve: what do you want from me ?
saurb has joined #ruby
<vectorshelve>
GoBin: if anyone could answer this question
<vectorshelve>
GoBin: thats all... sorry if i disturbd u
<ABK>
normally you gotta contact the admins/creator of that channel
<GoBin>
vectorshelve: sorry i cant help you with that....
<vectorshelve>
ABK: ok
chrxn_ has joined #ruby
<ABK>
actually you can ask these sort of Q at #freenode channel
<ABK>
they will be of more help
Engin has joined #ruby
<Engin>
how to make ruby apps load faster with mod_passenger ?
baniseterfiend` has joined #ruby
<Engin>
it is slow as hell at first start
<Engin>
there's this PassengerSpawnMethod I saw in the docs, but apparently my version of mod_passenger does not support it
<Engin>
or should I not care ?
<Engin>
because I'm at deployment phase right now, I'm restart apache a lot hence it is disturbing as hell... but normally maybe it would be ok ?
<Engin>
how do you guys do it ?
Sivart has joined #ruby
JStoker has joined #ruby
cymew has joined #ruby
bjensen has joined #ruby
stepnem has joined #ruby
baniseterfiend` has joined #ruby
stringoO has joined #ruby
tvw has joined #ruby
<cymew>
Have anyone successfully used a gem/library to access file systems extended attributes? I'm looking at a xattr gem, and the code at http://dinhe.net/~aredridel/projects/ruby/ruby-xattr and I can't get it to work. I'm a ruby newbie, so maybe I'm doing something wrong
davidpk has joined #ruby
bjensen has joined #ruby
cyri_ has joined #ruby
robert_ has joined #ruby
robert_ has joined #ruby
eldariof has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
ilyam has joined #ruby
saurb has joined #ruby
bluOxigen has joined #ruby
odinswand has joined #ruby
tilde` has joined #ruby
arturaz has joined #ruby
ghosTM55 has joined #ruby
AxonetBE has joined #ruby
<AxonetBE>
Somebody has also problems when rails/ruby launch an error? Everytime I have a method missing or routing error my laptop freeze because a high use of cpu and ram ( MBP late 2010 4GB ram I5 )
stoffus has joined #ruby
saurb1 has joined #ruby
triptec has joined #ruby
bgupta has joined #ruby
timonv has joined #ruby
momo__ has joined #ruby
robotmay has joined #ruby
don9z has joined #ruby
don9z has quit [#ruby]
banseljaj has joined #ruby
eka has joined #ruby
BiHi has joined #ruby
AxonetBE has joined #ruby
BiHi has joined #ruby
fr0gprince_mac has joined #ruby
berkes has joined #ruby
bluehavana has joined #ruby
ephemerian has joined #ruby
bluehavana has quit [#ruby]
dv_ has joined #ruby
QaDeS has joined #ruby
dv_ has joined #ruby
phantomfakeBNC has joined #ruby
pipu has joined #ruby
iocor has joined #ruby
<shevy>
hmm
andreime has joined #ruby
<shevy>
is there a way to easily set an array to keep only 5 members
<shevy>
should I probably subclass from Array and handle addition to the array on my own?
<shevy>
"if addition would lead to more than 5, prevent that" perhaps
Ferdev has joined #ruby
<banisterfiend>
shevy: if the array is an ivar you could just control access to it through instance methods and check for size then
<shevy>
oh
<shevy>
that would be even easier than subclassing
<shevy>
I guess I'll do that, the array is keeping track of an inventory of a character ... @layers[:inventory] = []
<shevy>
only 5 slots will be displayed from within the GUI lateron
<shevy>
I watched the simpsons a long time ago with the dolphins taking over springfield
<shevy>
since that day I knew that dolphins are evil beings with a cute smile
<matti>
shevy: Last time this position was taken by Koalas?
<matti>
shevy: Or Pandas?
<shevy>
dunno, I never liked Koalas or Pandas much
<matti>
I don't precisely remember.
<shevy>
but I used to watch Flipper when I was young
<matti>
shevy: And the damage was done ;p
<shevy>
Koalas remind me of those ... sloths, the most useless animal alive
<banisterfiend>
matti: remember when you had certain men on this channel you used to always wink at?
<banisterfiend>
matti: dont do that anymore? :)
<lolmaus>
How do i clear a line in console after "print foo"?
<banisterfiend>
lolmaus: use puts instead
<banisterfiend>
puts foo
fr0gprince_mac has joined #ruby
EddieS has joined #ruby
<rippa>
lolmaus: print "\n"
<matti>
banisterfiend: I wint at everybody.
<matti>
banisterfiend: wink*
<matti>
banisterfiend: I just habitually type smily face.
<lolmaus>
banisterfiend, rippa, i want to remove previously printed text
<lolmaus>
It's kinda status indicator
<banisterfiend>
lolmaus: read about ansi codes
<matti>
banisterfiend: I don't remember ;/
<lolmaus>
banisterfiend, i tried printing this: CLEARLINE = "\r\e[0K"
<lolmaus>
But no luck
<shevy>
lolmaus use \r I think
<shevy>
and .flush
<lolmaus>
shevy, flush?
<rippa>
lolmaus: \e[2K
<rippa>
clears current line
<shevy>
yeah something like
<rippa>
works for me
<shevy>
R = "\r"; print R; STDOUT.flush
<lolmaus>
shevy, wouldn't it clear the whole screen?
<shevy>
hmm
<rippa>
flush doesn't clear anything
<rippa>
it flushes stdout
<banisterfiend>
rippa: hey rippsy
<rippa>
*flushes buffer
<rippa>
to stdout
<rippa>
banisterfiend: hi
<shevy>
lolmaus using \r does not work for you?
<banisterfiend>
rippa: you run osx right?
<rippa>
banisterfiend: no
snearch has joined #ruby
sv has joined #ruby
yakko has joined #ruby
<lolmaus>
\r works: it moves the cursor left. But it does not clear the line.
kreantos has joined #ruby
<lolmaus>
\e[0K and \e[2K simply output "[0K"
<yakko>
hi everyone, how do I list all directories in ruby within a given directory path?
kin9 has joined #ruby
kerframil has joined #ruby
Kambus has joined #ruby
<lolmaus>
BTW, i'm testing this on Windows
kin9 has quit [#ruby]
jmuniz has joined #ruby
<yakko>
lolmaus: ewwww
Seisatsu has joined #ruby
<Tasser>
yakko, Dir['**'] might work
<rippa>
lolmaus: you can try just printing a lot of spaces
<rippa>
on top of your line
<Tasser>
yakko, Dir['**/*'] gives you all files
<yakko>
Tasser: how can I filter only dirs ?
<rippa>
though escape sequences work for me
<yakko>
Tasser: oh I see
<Tasser>
yakko, nah, the above doesn't work. only the '**/*' part
<yakko>
Tasser: can you point me a webpage for those wildcharactering?
<Tasser>
yakko, or you can shell out: find -type d . # ;-)
<Tasser>
yakko, it's bash expansion/globbing
twelvechairs has joined #ruby
<Tasser>
yakko, what's the overall task?
<yakko>
Tasser: 1. list all directories only recursively, 2. list all files in each dir not recursively, 3. count lines of each file
yopp has joined #ruby
<yakko>
Tasser: help
canton7 has joined #ruby
fayimora has joined #ruby
thecreators_ has joined #ruby
ChampS666 has joined #ruby
<Tasser>
yakko, find . -exec wc -l {} \;
<yakko>
Tasser: how about files within a given dir non-reccursive?
S2kx has joined #ruby
<Tasser>
yakko, wc -l *
<yakko>
Tasser: oh cool
twn39 has joined #ruby
<yakko>
though it only worked for a single file
<Tasser>
yakko, go learn some bash ^^
<yakko>
Tasser: I'll need to schedule that
trivol has joined #ruby
<Tasser>
yakko, aka you'll never do it? ^^
<yakko>
Tasser: never for the moment
tilde` has joined #ruby
<Engin>
where should I get support for mod_passenger
theoros has joined #ruby
deadbea7 has joined #ruby
wang has joined #ruby
somnium has joined #ruby
shellox has joined #ruby
Afal has joined #ruby
triptec has joined #ruby
karinsofia has quit [#ruby]
Dreamer3 has joined #ruby
<yakko>
Tasser: Find.find("*", :type=>:d) ?
wayne[mobile] has joined #ruby
<yakko>
Engin: #ror
pavelz has joined #ruby
jmaister has joined #ruby
majoh has joined #ruby
randym has joined #ruby
frontendloader has joined #ruby
joey__ has joined #ruby
<pcboy_>
#ror? How many ruby/rails channels out there. I'm already on #RubyOnRails, #rails, #ruby and #ruby-lang.
fred has joined #ruby
<yakko>
pcboy_: it's a redirect channel
jeedey has joined #ruby
FlyingFoX has joined #ruby
<pcboy_>
yakko: Oh.
<Tasser>
yakko, huh? there's a find gem? ^^
<Tasser>
not even a gem
twn39 has quit [#ruby]
<yakko>
Tasser: require 'fin'
<yakko>
find
<Tasser>
yakko, but it doesn't support that much if you take a look at the sources
<Tasser>
yakko, I'd probably just shell out as mentioned above
<yakko>
Tasser: go learn some ruby lol
<yakko>
Tasser: how can I get 'find -type d' in a ruby array?
<yakko>
Tasser: done it .split("\n")
<yakko>
:D
<Tasser>
yakko, I do know ruby and I do know when to use the correct tools ;-)
<yakko>
thanks a lot
<yopp>
monin'
<Engin>
yakko: thanks
<Tasser>
yopp, but you can actually do something akin to Find.find
Engin has quit ["parting"]
saurb has joined #ruby
<yopp>
Yes, I can.
<yopp>
Yes, we all can.
<Tasser>
yakko, ^
<yakko>
a = `find -type d`.split("\n")
<Tasser>
yakko, it works, it's short, but not ruby. :-)
<yakko>
Tasser: whatever, I just need to count some lines from a mail list I got from a php friend
<shevy>
hehe
<yakko>
Tasser: too many folders =/
<Tasser>
yakko, :D
<yakko>
Tasser: but if I had said that some morron would have said "spamming isn't cool" =/
<shevy>
yakko you could iterate through the content with Dir['**/*'] something and then apply a .reject {|x| ! File.directory?(x) } to exclude dirs
<yakko>
shevy: I need a tree viewing on that
<Tasser>
yakko, lstree
<Tasser>
yakko, ehh, tree
<yakko>
omg, I said spam now I'm getting tons of help =D
csprite has joined #ruby
S1kx has joined #ruby
S1kx has joined #ruby
<Tasser>
you should have said sex-spam
<yakko>
hey guys, I'll be spamming a porn website, can I get some help on this file listing thing?
<Tasser>
s/spamming/grabbing/
<yakko>
how do I use "wc -l *" in a ruby way?
<Tasser>
Dir.pwd.entries # but I think the Dir api sucks a bit
justinmcp has joined #ruby
Helius has joined #ruby
<yakko>
Tasser: no... the system method sucks
<Tasser>
Dir.entries('.').map {|f| f.directory or [f, File.readlines(f).size] }.flatten
<Tasser>
imo trailing conditionals suck
Liothen has joined #ruby
<yakko>
I want it readable lol
<yakko>
Dir.entries
<yakko>
good to know
jlebrech has joined #ruby
<Tasser>
yakko, foobar.baz.hello.there if something.else - something.else and foobar.baz.hello.there - somewhat better if the condition is first imo. Choose your own style
<yakko>
Tasser: is there a Dir.entries that lists onlydirs?
<Tasser>
yakko, see f.directory? or # ups, error
<Tasser>
yakko, a directory is a file as well in UNIX
<yakko>
Tasser: when file-handling is the ONLY time I actually miss .NET
Nathandim has joined #ruby
<Tasser>
yakko, I'm not sure how windows handels file/directories
<yakko>
Tasser: .NET framework is awesome on that specific part
<Tasser>
hm, oke
<Tasser>
can't tell :-)
<yakko>
Tasser: it's among their 5 (only) reasons to use .NET
<banisterfiend>
yakko: considering you seem to barely know the ruby file/directory API i dont think you're in a positin to say .NET does this part better ;) (yet)
<yakko>
banisterfiend: 5 years
<Tasser>
banisterfiend, they kind of miss a 'path' object
<Tasser>
banisterfiend, as well as the ruby time stuff needs an 'intervall' object ;-)
<shevy>
well we can make a .NET like framework for ruby
<yakko>
Tasser: I'm pretty sure somebody made a good file api somewhere, it's just not so well known
Mekkis has joined #ruby
<shevy>
we have some individual components
<shevy>
like pry to inspect every object at runtime
vandemar has joined #ruby
<shevy>
btw I hate Pathname.new
<shevy>
I think the world would be a better place if Pathname would be removed
<matled>
shevy: what do you dislike about pathname?
<shevy>
if I would redo ruby, I'd use File and Dir solely. Pathname and FileUtils would be gone.
ikaros has joined #ruby
phux has joined #ruby
tvo has joined #ruby
My_Hearing has joined #ruby
dibri has joined #ruby
justinmcp has joined #ruby
CacheMoney has joined #ruby
lorandi has joined #ruby
<yakko>
Tasser: can I make Find.find('.').map {|f| } have f as a fullpath name?
saurb has joined #ruby
<Tasser>
yakko, my short observation of the source tells me you can't
<yakko>
Tasser: thanks I think I can prepend it anywanys =)
chrxn_ has joined #ruby
trivol has joined #ruby
<Tasser>
yakko, how so?
<yakko>
File.join(base_path, dir, f)
<yakko>
Tasser: now I'm in question...
<yakko>
Tasser: should I rename "city.txt" to "5000 - city.txt"
<yakko>
or should I make a db table with path and count of files? =/
<Tasser>
what do you want to do with it?
<shevy>
hmm
<shevy>
I think it is not a good idea to add too much meta information into the filename itself
<shevy>
If you have to make a db anyway, you can keep track of the information in it or?
Kingsy has joined #ruby
<Kingsy>
anyone in here use capistrano? I know its offtopic but I am stuck and no-one is around in the support channel.. thought I would ask around?
davidpk has joined #ruby
<shevy>
I dont use capistrano, perhaps someone else does here
voodoofish has joined #ruby
Nathandi_ has joined #ruby
<Tasser>
hm, didn't know that the "\n" part of puts isn't threadsafe
Asher1 has joined #ruby
Nathandim has joined #ruby
chaitanya has joined #ruby
trivol has joined #ruby
andreime has joined #ruby
iocor has joined #ruby
havenn has joined #ruby
_obiJuan has joined #ruby
yakko has joined #ruby
krz has joined #ruby
krz has joined #ruby
fayimora has joined #ruby
dibri has joined #ruby
dibri has joined #ruby
anoNxeRo has joined #ruby
Talvino has joined #ruby
emmanuelux has joined #ruby
dibri has joined #ruby
krz has joined #ruby
Maarius has joined #ruby
<Maarius>
Okay guys, I am stuck with the following problem for days now, so any help would be absolutely appreciated. Following situation: I use RoR to communicate with a PHP based API throught GET and POST requests. Some of the requests require an AUTH cookie, which I manually send in the header like this: @tmp_result = Net::HTTP.get(URI.parse('example.php'),nil, {'Cookie' => session[:AUTH]}). However, although it is send in the header, it is somehow
<Maarius>
passed through. Do you have any idea why the cookie is not presented to example.php or any other method I could use for the get request?
nari has joined #ruby
banisterfiend has joined #ruby
sdwrage has joined #ruby
randym has joined #ruby
ph^ has joined #ruby
gvt has joined #ruby
berserkr has joined #ruby
Sliker has joined #ruby
Sliker has joined #ruby
chimkan__ has joined #ruby
chimkan__ has joined #ruby
saurb has joined #ruby
_obiJuan has joined #ruby
randym has joined #ruby
mengu has joined #ruby
iocor has joined #ruby
speggey has joined #ruby
Karmaon has joined #ruby
wyhaines has joined #ruby
<lolmaus>
How do i "save" a code block into a variable?
<gyre007>
why is the $1 variable in matched regexp group available in block when doing substitution and not directly in gsub ?
<Tasser>
think of the order of evaluation
<gyre007>
Id assume that when the code reaches $1.upcase it would've already $1 available...unless it somehow compiles the whole string1.gsub!() part and in that case Id understand
zommi has joined #ruby
<Tasser>
gyre007, ruby doesn't compile, it evaluates ;-)
<Tasser>
think of when the argument list is evaluated
<gyre007>
Tasser, ok so that's what I meant :)
<gyre007>
I guess it makes sense
fortysixandtwo has joined #ruby
jergason has joined #ruby
Jackneill has joined #ruby
Jackneill has joined #ruby
ryannielson has joined #ruby
wroathe has joined #ruby
fayimora has joined #ruby
Sailias has joined #ruby
mkscrg has joined #ruby
davidpk has joined #ruby
momo__ has joined #ruby
yfeldblum has joined #ruby
tvo has joined #ruby
pu22l3r has joined #ruby
berkes has joined #ruby
icrazyhack has joined #ruby
trivol has joined #ruby
jxpx777 has joined #ruby
jxpx777_ has joined #ruby
tatsuya_o has joined #ruby
<cymew>
ok. I have a hard time understanding the syntax of hashes, always had (I hate perl hashes). So say I iterate over a bunch of files and wants to store the filename in a hash, with the md5sum as a key. Why doesn't this work? "list{#{file} => #{md5sum}} "
<cymew>
YEah, I have read the manual, I still don't get it.
cantbecool has joined #ruby
icrazyhack has joined #ruby
jxpx777- has joined #ruby
jxpx777_ has joined #ruby
tatsuya_o has joined #ruby
<wroathe>
cymew
<wroathe>
last[key] = value
<wroathe>
key can be either a string or a symbol
<wroathe>
generally prefereble to use symbols when possible
CannedCorn has joined #ruby
<wroathe>
So in your case you'd want list["#{filename}"] = "#{md5sum}"
yekta has joined #ruby
CannedCorn has joined #ruby
dcarper has joined #ruby
looopy has joined #ruby
<cymew>
ok, so the #{} makes it evaluate, and wrapping it in quotes makes it a string?
<wroathe>
Yeah.
<cymew>
and I messed up the [{ again...
<cymew>
I am a lisper, so I get easily confused when there's more than one kind....
<cymew>
Thanks
<wroathe>
I've never programmed in lisp
<cymew>
Great language. I find myself like ruby because it reminds me lots of lisp
tmiller has joined #ruby
kerframil_ has joined #ruby
badelat has joined #ruby
icrazyhack has joined #ruby
Indian has joined #ruby
<Tasser>
cymew, ever seen (let () ... ) in ruby? ;-)
<shevy>
hmm
<shevy>
I will kill people who try to use let () rather than let() !
<cymew>
Tasser: Nope, not yet. I started last week and have not get got hold of a reference to browse. Sounds familiar. :)
<Tasser>
shevy, lisp got lists only, so (let (var foo) ... ) is a call
<deryl>
let ()
<JonnieCache>
cymew: "#{md5sum}" is completely redundant and is equivalent to just md5sum
<Tasser>
cymew, well, I just read a bunch of stuff on lisp, never coded too much...
<JonnieCache>
actually md5sum.to_s
* shevy
kills deryl
<JonnieCache>
the #{} syntax is for string interpolation and its for cases like "this is my checksum: #{md5sum} there it is" instead of "this is my checksum: "+md5sum.to_s+" there it is"
<JonnieCache>
its like sprintf except less awful
linoj_ has joined #ruby
imsplitbit has joined #ruby
acidrain has joined #ruby
<cymew>
ok, I tried list["#{file}"] => md5sum.to_s instead and while I think I understand what it does this time, now I get a new error "syntax error, unexpected tASSOC, expecting kEND
fuffi has joined #ruby
<cymew>
list["#{file}"] => md5sum.to_s
<cymew>
^
<JonnieCache>
its the => you want just =
<cymew>
Ow, shoot.
<JonnieCache>
=> is part of the key => value hash syntax
<JonnieCache>
you just want list[file] = md5sum
<JonnieCache>
i wouldnt worry about converting everything to strings unless you have a specific need to
<shevy>
yeah, think: assign that value, to that key
<cymew>
I really can't seem to keep those apart. I am allgergic to syntax and the more kinds of funny characters I use the more confused I get. Considering I start out easily confused...
<shevy>
the less characters you use, the better
<JonnieCache>
cymew: id advise you to learn the fundamentals of the ruby language and then the syntax will seem less crazy
<shevy>
your_hash['colour'] = 'green'
<cymew>
hases are some kind of arrays, are they?
<JonnieCache>
the key is that almost everything is a method call
<shevy>
sort of
<shevy>
but you can use any key for them
<shevy>
for arrays, you can use only numbers... array[0] to get the first element, array[1] the second etc..
<cymew>
JonnieCache: that is the easy part, coming from lisp. Everything evaluates to something.
Knodi has joined #ruby
<tshirtman>
hashes are more like a dictionnary, you lookup an entry, and get the associated result
will_b has joined #ruby
<shevy>
just think of ruby as a place where objects happily live together
<tshirtman>
in fact i call hashes more often dictionnaries than hashes
<shevy>
yeah but ... Hash.new works, Dictionary.new does not :P
<Tasser>
Dictionary = Hash; Dictionary.new
<JonnieCache>
cymew: in ruby stuff that doesnt look like a method call actually is, for example with foo['bar'] = 'qux' you are calling a method called []= on foo
<JonnieCache>
with a special syntax
<tshirtman>
dict() works in python ;)
<shevy>
hehe tshirtman ;)
niklasb has joined #ruby
<cymew>
I'm plowing through the book "Programming Ruby" now, testing stuff as I go along, since it's boring to just read. I find myself getting stuck on the same things as in perl, funny characters and hashes...
* tshirtman
restrain from praising python here :P
<shevy>
oh yeah cymew ... use {} and [] rather than Hash.new and Array.new. the first two are a bit faster. and less characters, so double advantage here!
<shevy>
perl is a lot worse really
<shevy>
I can never recall what is $$ and $` and $:
<cymew>
perl is worse than everything, except teco
<shevy>
ok, the last one I know finally...
<cymew>
JonnieCache: Interesting example. You would wonder why you don't write foo.['bar'] though.
geekbri has joined #ruby
<tshirtman>
matz consider larry wall as his hero :P
<shevy>
hehe
<tshirtman>
so if you hate perl, i would suggest fearing ruby ;)
<JonnieCache>
cymew: ruby is opinionated when it comes to aesthetics of code. some like it and some dont, and that is intentional
<shevy>
shortcuts when it comes to syntax are good
<cymew>
JonnieCache: ah, aesthetics.
<geekbri>
I find ruby code to be generally much more readable than say..... perl :)
<shevy>
yeah
<tshirtman>
anything is more readable than perl
<shevy>
hmm
<tshirtman>
except assembly maybe
<shevy>
not sure about php
<cymew>
Larry Wall is a genious, no doubt about it. I just hate writing perl. I have reading it even more. Reading ruby is nice.
<JonnieCache>
it has been said that you could pipe line noise into the perl interpreter and have it execute
<shevy>
I'd say php is only a little bit more readable than perl
<cymew>
well, genius, anyway...
Matiasu has joined #ruby
<Matiasu>
Hello!
<geekbri>
I was ready a python book and they explained perl very well in it... ruby and python are very opinionated and fairly exact about how things are written.. where as perl is more like say.. the english language... you can do things MANY different ways and that can lead to some very .... unique code :)
gabeh has joined #ruby
kpshek has joined #ruby
<cymew>
back to reading and coding. Many thanks for the help and suggestions.
drknus has joined #ruby
<Matiasu>
I'm looking for a good book to learn Ruby, what are your suggestions?
<tshirtman>
well, i think "black pearl" show how much you can do with valid syntax in perl…
<shevy>
Perl sort of was an eternal hack upon other hacks. and then call it a programming language one day...
<tshirtman>
1/ am i using the good method to do such thing?
gabeh_ has joined #ruby
cantbecool has quit [#ruby]
<tshirtman>
2/ what could be wrong? :/ i tried to adapt what he does in init.rb, but no luck either
Nathandim has joined #ruby
<tshirtman>
(redmine question sorry)
krz has joined #ruby
DarkFoxDK has joined #ruby
prs` has joined #ruby
Skaag has joined #ruby
thrope has joined #ruby
__main__ has joined #ruby
<prs`>
how can i check if all elements in an array satisfy a predicate?
<prs`>
right now I'm doing arr.select {..}.length == arr.length
<prs`>
must be a nicer way
<thrope>
hi all - I am a ruby beginner trying to get it to work inside vim on windows. Vim is compled with dynamic ruby support... I have installed 1.9.1 from ruby-installer.com, but vim doesnt find the dll... I get could not load library msvcrt-ruby191.dll.... if I copy the dll to be next to the gvim executable than I can do basic stuff, but not load any packages from the standard library
<thrope>
so how can I get vim to load the ruby dll from the correct place?
<thrope>
do I need to restart the computer after ruby installation?
<thrope>
(I have logged out of my user account but restarting the system is difficult)
<JonnieCache>
thrope: youre running ruby and vim yet you use windows? i guess thats been forced upon you?
gabeh has joined #ruby
<thrope>
JonnieCache: yes
<Tasser>
JonnieCache, windows does not like ruby, rubygems does not like linux, so you're stuck with mac?
<thrope>
actually I almost get it working but I get an "unknown encoding name - latin1" (eval):788 in `force_encoding` ...
<JonnieCache>
rubygems is fine on linux
<thrope>
but I am not sure if that is coming from vim or ruby
<JonnieCache>
as long as you dont try and fuck with the debian packages
PragCypher has joined #ruby
viniciuskastrup has joined #ruby
prs` has quit ["ERC Version 5.3 (IRC client for Emacs)"]
senthil has joined #ruby
denom has joined #ruby
rippa has joined #ruby
<Tasser>
JonnieCache, well, it's the two sides - an own package manager, or use the one of your distribution. It kinda sucks if you want to install redmine via your package manager and have to use rubygems as well...
<Tasser>
mac doesn't have that problem ;-)
<Tasser>
</rant>
<JonnieCache>
yeah it does. osx comes with its own old ruby and its own old rubygems and theres no neat way to replace them
<JonnieCache>
so everyone builds their own like they do on debian
<JonnieCache>
but as osx is only used for dev and almost never for deployment/production it doesnt casue problems
<Tasser>
they have a different problem, not the one with rubgems
Asher has joined #ruby
AutoMan has joined #ruby
DuoSRX has joined #ruby
<JonnieCache>
imo its an inevitable problem with ruby's demented pace of change. if we want to carry on waking up every morning, cding into our project dir and running `bundle update` with all our deps pointed at the HEADs of github repos, then we're gonna have to accept that this comes at a price of friction with OS distributers
twock has joined #ruby
AutoMan has quit [#ruby]
<JonnieCache>
(not that everyone does that, but it is common)
PaciFisT has joined #ruby
bjensen has joined #ruby
punkrawkR has joined #ruby
tweeKula has joined #ruby
wyhaines has joined #ruby
bitrot has joined #ruby
axl_ has joined #ruby
MrGando has joined #ruby
enherit has joined #ruby
kaiwren has joined #ruby
fr0gprince_mac has joined #ruby
<shevy>
JonnieCache should ruby development have to be slow because packagers are unable to package ruby?
philcrissman has joined #ruby
<JonnieCache>
no
<JonnieCache>
but we should have understanding when the packagers get upset
<etehtsea>
I just think that they should leave ruby gems alone and don't try to package every gem
<shevy>
hmm
<shevy>
anyone knows their rationale for not allowing gems to handle dependencies?
<JonnieCache>
sysadmins dont like not having centralised control over every bit of code on their boxes
JonSchuff has joined #ruby
<JonnieCache>
the idea that developers should be able to go around managing their own dependency versions is abhorrent to the sysadmin philosophy
<nim_>
i have a class first with attributes y,y in a second class i create an attribute k from the first class when i go to access the k.x i'm taking the following error undefined method `x' for nil:NilClass (NoMethodError)
<nim_>
any idea?
<JonnieCache>
which is understandable when you're solely responsible for the security and smooth running of hundreds of servers
<shevy>
nim_ pls upload code
<shevy>
your object does not exist
<shevy>
k.x
<shevy>
k is nil for whatever reason
bluenemo has joined #ruby
bluenemo has joined #ruby
emocakes has joined #ruby
iocor has joined #ruby
punkrawkR has joined #ruby
emocake has joined #ruby
fayimora_ has joined #ruby
csavola has joined #ruby
namidark has joined #ruby
chimkan has joined #ruby
punkrawkR has joined #ruby
v0yager has joined #ruby
thecreators has joined #ruby
twelvechairs has quit [#ruby]
wmoxam has joined #ruby
milktrader has joined #ruby
Sliker has joined #ruby
milktrader has quit [#ruby]
<theRoUS>
does anyone know if there's a gem for making a string http-header-field-value-safe? as in removing/editing any characters illegal in such a value?
dfr|work has joined #ruby
n3m has joined #ruby
moshef has joined #ruby
iocor has joined #ruby
brandonhilkert has joined #ruby
<brandonhilkert>
If you have a class with attr_accessor :color, when accessing from within the class better to use @color or color?
philcrissman has joined #ruby
andrewhl has joined #ruby
brandonhilkert has quit [#ruby]
hukl has joined #ruby
phantomfakeBNC has joined #ruby
havenn has joined #ruby
dennda has joined #ruby
twoism has joined #ruby
mikepack has joined #ruby
lateau_ has joined #ruby
ckrailo has joined #ruby
Shamgar has joined #ruby
adeponte has joined #ruby
iain12324 has joined #ruby
<Synthead>
is there a cleaner way to install the passenger module other than passenger-install-apache2-module? I'd really prefer the files to be installed by my package manager (apt on debian)
bluOxigen has joined #ruby
bluOxigen has joined #ruby
<tshirtman>
Synthead: there is a libapache2-mod-passenger
<tshirtman>
i installed it like this
blueOxigen has joined #ruby
<tshirtman>
in depos
<tshirtman>
repos*
<Synthead>
tshirtman: will that work with ruby enterprise edition?
<tshirtman>
no idea, i used it to deploy redmine, it works, that's all i know :P
<Synthead>
tshirtman: I might have to pack it myself, heh. no biggie.
ph^ has joined #ruby
saurb has joined #ruby
shell0x has joined #ruby
iMe has joined #ruby
jgrevich has joined #ruby
rootkit has joined #ruby
|DM| has joined #ruby
<|DM|>
Hello.
<Synthead>
|DM|: hey
<rootkit>
hi
* Synthead
gets owned by rootkit
<Synthead>
ah shit!
<|DM|>
so, I have a coding competition in ruby coming up soon in school
<rootkit>
:D
<|DM|>
I was wondering where I could pick up some skills
<JonnieCache>
thats like asking is spaghetti bolognese better than wheat
<|DM|>
weird question, but what the holy fuck is "=>" ?
virunga has joined #ruby
<JonnieCache>
its part of the hash syntax
<nmxdij4e-\>
equalTo AND greater than
<JonnieCache>
oh yeah and that
jlogsdon has joined #ruby
<rootkit>
what is a hash
pseudonymous has joined #ruby
IAD has joined #ruby
<JonnieCache>
confusingly people sometimes also use it to mean "the preceding code returns this"
<rootkit>
i dont do drugs...
<nmxdij4e-\>
#
<|DM|>
"hash syntax" ?
<JonnieCache>
a hash is a map of keys to values. if you dont kow this you should probably follow the pogniant guide to ruby or some similar beginners guide. those links i posted are quite advanced
<pseudonymous>
If I have a class, ItemSet, with a private field, data - and I want to basically delegate ItemSet.each (the block it's passed) to ItemSet.data - how would I do it ?
<rippa>
JonnieCache: that's because of irb
<rootkit>
how about rubyonrails
macmartine has joined #ruby
<Synthead>
(#)====O
<Synthead>
bong
alecs has joined #ruby
<alecs>
hello
<rootkit>
hi
<Synthead>
HI THERE
<rootkit>
what kinda programs can i c0d3 with rubee ?
<tshirtman>
|DM|: i think you want to pick a tutorial, not ask everything about the langage here :)
<Synthead>
rootkit: ruby is just a fork of java, so minecraft, but only if you are smart
hubub has joined #ruby
<rootkit>
that sounds nice
<Synthead>
yeah!!!!
<rootkit>
i do play minecraft a lot.
<|DM|>
tshirtman: true, but what I did was a halfhearted attempt to troll. the community is too nice though; rootkit told me to help him troll here. I'm sorry.
dv310p3r has joined #ruby
<tshirtman>
…
<gift>
lol, ?
Ownatik has joined #ruby
<virunga>
U make a Ninja wanna fuck
<gift>
you guys make a terribad team :P
<rootkit>
huh?
<|DM|>
I know, that's why I defected.
<pseudonymous>
please ? I just want to delegate the .each method to a privately contained data member
<geekbri>
fail troll.
<rootkit>
dont involve me. thats bullying.
<Synthead>
one time I was like, "notch, I need some new blocks," and he was all, just download dem gemz here and I was all gem install and stuff but be was like "you are a stealer" and sued me for like millions of dollars so now I just work for free and chat on freenode
<rootkit>
haha
<alecs>
i have a small problem using ruby 1.9.1 (ruby 1.9.2p0 (2010-08-18 revision 29036) ) on debian squeeze ... and i dunno how to fix it http://pastebin.com/n4atMrzw (i am using rails 3.2.0)
<rootkit>
that guy is pasting some nonsense, i never spoke to him
<nmxdij4e-\>
pastebin is full o nonsense
<tshirtman>
silly silly rootkit
<Deele>
for arrays, what range will be "from third, up to last"?
<tshirtman>
we will bully him into a tree, i like trees
<virunga>
|DM|, why did you save the dialog?
<rootkit>
i am a legit person, this guy got banned in #programming.
<pseudonymous>
bump Is there any intelligent life in here ?
<|DM|>
virunga: that happened minutes ago, I simply copied the screen.
<rootkit>
just /ignore |DM|
<nmxdij4e-\>
jimmy_birer ?
perturbedpanda has joined #ruby
kenperkins has joined #ruby
<rootkit>
i am sure that if you people had more time to ACTUALLY ignore the trolls, you would be able to do more things.
<tshirtman>
ofc
<virunga>
rootkit, what's a troll?
<rootkit>
not sure
<rootkit>
some sort of creature
samsonjs has joined #ruby
<virunga>
rootkit, how people become trolls? :)
<nmxdij4e-\>
a movie
<rootkit>
by doing.
<nmxdij4e-\>
and game
<nmxdij4e-\>
and cartoon
<JonnieCache>
pseudonymous: in rails theres a `delegate` method, i think its part of activesupport
kpshek has joined #ruby
<JonnieCache>
maybe have a look at that
<nmxdij4e-\>
they visit mars>?
<nmxdij4e-\>
sdklfpld
<rootkit>
mars could be in ruby.
eldariof has joined #ruby
<nmxdij4e-\>
rubyonrails can easily quickly make games ?
<JonnieCache>
you could just do `def each(*args); data.each(*args); end
<JonnieCache>
or something like that
<rootkit>
yes
<rootkit>
make games with rubyonrails
<tshirtman>
i guess it's obvious who is the troll now :)
<pseudonymous>
JonnieCache: thanks - was beginning to think no one could see me for whatever reason. Though I found a better solution just now. Prefix the last arg with an ampersand (&) - that arg is now the block. then inside you write 'datavar.each $blockvar' and you're done :)
<JonnieCache>
yeah thats how you specify the block
<rootkit>
so where can i find more about ruby and gems?
<JonnieCache>
but if you do *args like that it just captures everything i think, although maybe not the block as well
<JonnieCache>
the * splat syntax is very handy
<JonnieCache>
so i wonder who decided to organise an invasion?
jergason has joined #ruby
niklasb has joined #ruby
daniel_hinojosa has joined #ruby
<JonnieCache>
Deele: 3..-1 i think
<JonnieCache>
or 3..array.length
<Deele>
thx
IrishGringo has joined #ruby
coucher has joined #ruby
rootkit has quit ["Konversation terminated!"]
sentry has joined #ruby
<sentry>
anyone ever had troubles loading oci (oracle) libraries into ruby ? 1.9.2 version
sorin has joined #ruby
<sorin>
Hello.
mafolz has joined #ruby
<sorin>
I'm having encoding troubles with Ruby 1.9.3 and YAML. I have two strings that look identical to the eye. Both times Ruby claims that the encoding is UTF-8, but one has length 51 while the other 54.
<sorin>
54 is the right length. YAML does something to the string.
youdonotexist has joined #ruby
<virunga>
bad YALM
<virunga>
YAML :P
<virunga>
maybe some space
<virunga>
somewhere
waxjar has joined #ruby
bbttxu_ has joined #ruby
fallen has joined #ruby
lkba has joined #ruby
* tshirtman
would use vimdiff to see where is the different between the two strings
<tshirtman>
however, a loop over the chars of the strings in any language would work
<tshirtman>
never trust your eyes
td123 has joined #ruby
<tshirtman>
о ≠ o for example
jingoro has joined #ruby
<Deele>
why '@stuff'[0].kind_of?(Symbol) is false?
gvt has joined #ruby
michaelh has joined #ruby
enherit has joined #ruby
<Tasser>
Deele, because it's a string
blueadept has joined #ruby
blueadept has joined #ruby
<davidcelis>
LOL.
albemuth has joined #ruby
Deele has joined #ruby
<waxjar>
'@stuff'[0] # => "@" :)
<Deele>
Tasser, one guy here told me, that would help me find, if first char of string is symbol
<Deele>
would you suggest other method?
<JonnieCache>
youre confused as to what a symbol is
<davidcelis>
i dont think that "symbol" means what you think it is
<waxjar>
i think you're confusing the ruby Symbol and symbols such as #$!@#%^
<JonnieCache>
ahhhh good point
<Deele>
I think, that guy who suggested, confused :)
<waxjar>
Symbols are these things `:symbol`
hydrozen has joined #ruby
<davidcelis>
:stuff
<davidcelis>
that is a symbol
<davidcelis>
no quotes or anything. just text prepended by a colon
Skaag has joined #ruby
<Deele>
so, should I use regex
<Tasser>
like :sex n stuff
pseudonymous has quit [#ruby]
<waxjar>
yeah, regular expressions are useful in this case
<JonnieCache>
Deele: regex was what i was going to suggest
<Deele>
I have bunch of strings in array, I'm looping over, getting out the ones, that has prefixed with symbol
jwmann has joined #ruby
<JonnieCache>
something like /$[\W\D]/
<Deele>
what would be syntax for if...else statement?
<JonnieCache>
Deele: @names.select {|n| n =~ /$[\W\D]/ }
<waxjar>
Deele, use map or each instead of each_index (look them up in the documentation to see why) :)
<JonnieCache>
i suggest reading a ruby book
award85 has joined #ruby
<waxjar>
forget that, listen to JonnieCache :P
<Deele>
JonnieCache, I'm going for reverse learning
<JonnieCache>
interesting...
Shamgar has joined #ruby
p0y has joined #ruby
linoj__ has joined #ruby
jergason has joined #ruby
prs` has joined #ruby
<Deele>
waxjar, you, with map, made this more confusing
<waxjar>
my job here is done :D
<Deele>
I need Array['@name', 'name2', '%name3'] conversion to Hash['name'=>'@', 'name2'=>'', 'name3'=>'%']
cloke has joined #ruby
GiambalaGiambala has joined #ruby
<Deele>
so, I'm iterating over array, getting first letter, checking, adding new hash item
SegFaultAX|work has joined #ruby
<davidcelis>
... reverse learning?
Sailias has joined #ruby
<prs`>
is it possible to rescue an exception inside an each enumerator. Was thinking of something like in this (invalid) code snippet: https://gist.github.com/d31b19a366a27346d1df
<waxjar>
read an article or two about arrays and hashes and ask again if you don't understand Deele :)
<Deele>
waxjar, so, you dont like teaching...
<davidcelis>
return something(elem)
<davidcelis>
you're just gonna return before any rescuing
<davidcelis>
that enumerator's gonna run... once?
<prs`>
no, the function throws
<waxjar>
Deele it seems to me like you don't like reading :p
<davidcelis>
no, why the "return" statement?
<prs`>
just to illustrate what I'm trying to do
<waxjar>
plus i'm not teaching anything if i tell you exactly what to do, is it? :)
<prs`>
return the output of something for the first elem in arr that does not make something throw
<prs`>
if that made sense
burgestrand has joined #ruby
<Deele>
waxjar, depends on the one, receiving information
C0NNER has joined #ruby
<davidcelis>
but the return itself will throw, dude
<davidcelis>
you can't stick a return in an each
<davidcelis>
that throws a LocalJumpError
<prs`>
aha, so what youre saying is that you cannot shortcircuit an each with a return
<davidcelis>
yes
<davidcelis>
wouldn't make sense anyway
<davidcelis>
it would just make the enumerator cease
seivan has joined #ruby
<waxjar>
Deele: my point is, you still won't understand how and why it works. read up a bit on arrays and hashes (google is your friend) and come back if you still don't understand (which I highly doubt) :)
t0mmyvyo has joined #ruby
<Deele>
waxjar, I always crawl in google, before asking
Richmond has joined #ruby
<Deele>
waxjar, just hoped, that someone will make it easier...
<davidcelis>
Deele: honestly, we aren't really here for teaching. this channel is for questions, sure, but this isn't really a place to learn everything about ruby.
<davidcelis>
read through a ruby book, check out the docs
<Deele>
davidcelis, wow, I KNOW, that is not correct
<davidcelis>
sure it is. #ruby is not a Ruby tutorial :)
Araxia has joined #ruby
<geekbri>
return will return from the lexically calling method i believe. perhaps you want next ?
<Deele>
even if I'm newbie with ruby, have been in php, regex, jquery and other channels as helper, there is other situation
iocor has joined #ruby
<geekbri>
LocalJumpError usually means that the method you are trying to return from has already returned...at least if i remember correctly thats what it usually means :)
<davidcelis>
geekbri: Tried it out in IRB, it's thrown literally when a return statement is encountered at the top level of the each
<davidcelis>
geekbri: As in, that would return from each?
<geekbri>
davidcelis: the "return" call basically says "return from the last lexically scoped method" if i remeber correctly
nacengineer has joined #ruby
<geekbri>
no
<geekbri>
oh well maybe
<davidcelis>
geekbri: Pretty sure you just can't stick a return statement in a block
<geekbri>
davidcelis: well you can, if you want it to have an error.
<robacarp>
in a block you want to use break
<davidcelis>
lol.
<davidcelis>
Touché, geekbri. Touché.
robert_ has joined #ruby
thecreators has joined #ruby
maletor has joined #ruby
<JonnieCache>
i always assumed that the "last expression automatically returned" behaviour in blocks was the same as the "last expression automatically returned" bheaviour one sees in methods
carlyle has joined #ruby
<robacarp>
JonnieCache: well, it is, more or less.
<robacarp>
its just not returning
<geekbri>
davidcelis: I'm certainly not an authority.. I was just saying... from the depths of my bad memory.. that return is used to return from the last calling method (lexically I believe). So using return in a block will cause it to try to return from the last method that called whatever the block is running under. The block itself isn't a method so it doesn't return from that so to speak.
<robacarp>
the block is evaluating to that value.
<JonnieCache>
i guess so. can you not use return in a proc then either?
<davidcelis>
geekbri: urrite
<davidcelis>
geekbri: Stuck it in a method, it returned from the method
<burgestrand>
JonnieCache: give it a try
<robacarp>
JonnieCache: yea, best try it
<robacarp>
I think procs behave more like methods but I use them rarely
<geekbri>
davidcelis: right so to break from a block you can use either next or break. the difference being break will break from a block and an interator and next just breaks from the block and returns to an iterator
<geekbri>
JonnieCache: be careful with return in procs... because if whatever method called that proc has returned already you will get a LocalJumpError.
<Deele>
ged, those are named capture groups?
<ged>
Deele: yes.
<Deele>
ged, looks good, thanks
<geekbri>
JonnieCache: if you want to "return" from a proc, you really want to be using lambdas. A return from a lambda does more what you think it does.
<JonnieCache>
i dont need to do either, it was just a random question
<JonnieCache>
but thanks :)
<geekbri>
JonnieCache: ah :) well in that case. Return from a lambda returns from the lambda.. where as return from a Proc returns from whatever method called the proc.
<geekbri>
JonnieCache: returning from the lambada will always be ok... returning from the proc may or may not cause a localjumperror (and you shouldn't do it!)
krz has joined #ruby
headius has joined #ruby
<robacarp>
JonnieCache: you mean to tell me all this is just an academic discussion?! well, okay
<JonnieCache>
lol
yeltzooo has joined #ruby
omry has joined #ruby
<sarkis>
JonnieCache: amazing nick lol
<regedarek>
Hello guys! especialy girls
<geekbri>
academic discussions are useful..... sometimes :)
<regedarek>
anybody could give some advice about testing gems??
<robacarp>
regedarek: your own gems or third party gems?
<Deele>
ged, just needed to remove same name of memo object and new hash, and it worked
<regedarek>
but which part i should first test?? initializer ?
<regedarek>
connection
<regedarek>
robacarp: this is third-party gem
<JonnieCache>
regedarek: knowing what to test is the hardest thing about testing
<robacarp>
regedarek: I see. Well, you shouldn't be testing the gem internals, just that it does what you expect.
<robacarp>
given that, it doesn't matter what you test first....just that you test
iamsiva11_ has joined #ruby
Jay_Levitt has joined #ruby
apok has joined #ruby
prs` has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<regedarek>
hmm so in agent module i tried to test connection but i think my "test" dont do that :)
leoncame` has joined #ruby
<regedarek>
this before block is right way to initialize @agent ??
adeponte has joined #ruby
davidpk has joined #ruby
alagabes1 has joined #ruby
<alagabes1>
hello, I've a question about each, lets say I've a lambda expression like {|e| p e }. How can I tell how many elements did't I already proceed?
visof has joined #ruby
<alagabes1>
s/did't/have/
<JonnieCache>
there's each_with_index
<JonnieCache>
which yields a counter along with the object
hadees has joined #ruby
ryannielson has joined #ruby
MrGando has joined #ruby
<alagabes1>
JonnieCache: thanks, that's what I've looked for
apok has joined #ruby
Nathandim has joined #ruby
<JonnieCache>
each_pair is a good one too
<JonnieCache>
oft overlooked
<robacarp>
each_cons
alfism has joined #ruby
twqla has joined #ruby
<JonnieCache>
ooooh, lispy
tehgeekm_ has joined #ruby
<robacarp>
;-)
ph^ has joined #ruby
<alagabes1>
how can I ignore specyfied elements in each?
alex__c2022 has joined #ruby
<alagabes1>
Do I have to remove elements from array in before?
viper1092 has joined #ruby
jcromartie has joined #ruby
<JonnieCache>
filter the array with reject or select, then call each on the result
_theriffer_ has joined #ruby
sogeking99 has joined #ruby
<sogeking99>
hey guys, what editor do you guys use?
<robacarp>
alagabes1: you can also look for them and next
<robacarp>
sogeking99: vim
<alagabes1>
That's what I thought, sorry for lame questions but I've just started to learn, and i thought it exists some fancy, ruby-like way to do so :)
adamkittelson has joined #ruby
<alagabes1>
robacarp: I really need to keep my counter
<robacarp>
alagabes1: yea, reject or keep is a better way regardless
<sogeking99>
I am using gedit. I have it saved as a .rb but should 'gets' and 'print' have a coloured highlight? because only strings seem to
<geekbri>
my solution: use vim ;)
baroquebobcat has joined #ruby
stayarrr has joined #ruby
ph^ has joined #ruby
JohnBat26 has joined #ruby
<sogeking99>
yeah vim displays it the same. Do I need to download a plugin or something?
apok_ has joined #ruby
philcrissman has joined #ruby
chimkan has joined #ruby
nfluxx has joined #ruby
<sogeking99>
?
Russell^^ has joined #ruby
zomgbie has joined #ruby
<robacarp>
sogeking99: do you have syntax highlighting turned on?
gabeh_ has joined #ruby
Mekkis has joined #ruby
philips has joined #ruby
<sogeking99>
robacarp, yeah. it's the same on geany. things like puts, print, reverse and upcase don't highlight at all, only strings do.
<sogeking99>
Is this just the way ruby is?
<robacarp>
oh, yea, because those aren't keywords they're method calls
<robacarp>
class/def/end/if/then/else/super are keywords
Seppman has joined #ruby
<robacarp>
(as an example...)
<sogeking99>
oh right
stephans has joined #ruby
baroquebobcat has joined #ruby
tweeKula has joined #ruby
omry has joined #ruby
AxonetBE has joined #ruby
fallen has joined #ruby
remink has joined #ruby
akem has joined #ruby
wilmoore has joined #ruby
AxonetBE has joined #ruby
hukl has joined #ruby
jxpx777 has joined #ruby
yakko has joined #ruby
jxpx777_ has joined #ruby
yakko has quit [#ruby]
hukl_ has joined #ruby
tvo has joined #ruby
tvo has joined #ruby
ChampS666 has joined #ruby
gvt has joined #ruby
shadoi has joined #ruby
sdwrage has joined #ruby
RaggedJack has joined #ruby
baroquebobcat has joined #ruby
voodoofish430 has joined #ruby
hukl has joined #ruby
badabim has joined #ruby
zomgbie has joined #ruby
shadoi has joined #ruby
namidark has joined #ruby
thrope_ has joined #ruby
philcrissman has joined #ruby
kerframil has joined #ruby
sorin has joined #ruby
mrsolo has joined #ruby
fr0gprince_mac has joined #ruby
sonkei has joined #ruby
cbuxton has joined #ruby
ests has joined #ruby
baroquebobcat has joined #ruby
samuel02 has joined #ruby
apok has joined #ruby
Guest90579 has joined #ruby
lagos has joined #ruby
canton7 has joined #ruby
nd__ has joined #ruby
Shamgar has joined #ruby
CacheMoney has joined #ruby
gvt has joined #ruby
<Ownatik>
How can I get the root directory of a project, from within the code of a gem which is included in that project?
Karmaon has joined #ruby
kpshek has joined #ruby
lagos has joined #ruby
t0mmyvyo has joined #ruby
csherin has joined #ruby
<JonnieCache>
File.expand_path(File.dirname(__FILE__), "..", "..") and so on
<JonnieCache>
theres probably a less godawful way of doing it but i cant remember
<JonnieCache>
the godawfulness of that code implies you shouldnt need to do it
dv_ has joined #ruby
luxurymode has joined #ruby
ctp has joined #ruby
zakwilson_ has joined #ruby
cableray has joined #ruby
fred has joined #ruby
dfr|work has joined #ruby
quebre has joined #ruby
<quebre>
hello
burgestrand has joined #ruby
<quebre>
i have strange problem, i'm trying to install chiliproject - and im supposed to run "RAILS_ENV=production bundle exec rake db:migrate" command that gives me following error:
kindkid has joined #ruby
Sailias has joined #ruby
<quebre>
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
<quebre>
the problem is, that i already installed the mysql via "gem install mysql" 100 times
<quebre>
and it still shows me that error
<quebre>
what im doing wrong ?
coucher has joined #ruby
dnyy has joined #ruby
cirno has joined #ruby
<epochwolf|vps>
quebre: you're using bundler, installing gems to your system ruby won't help
t0mmyvyo has joined #ruby
<epochwolf|vps>
if you're*
<kindkid>
I got an "invalid byte sequence in UTF-8" error in production, so I found some code online that should fix it (using iconv or String#encode)… My problem is that I don't know how to create an invalid byte sequence in the first place so that I can test the fix.
<kindkid>
Anyone have a suggestion for how to do so in irb?
<quebre>
epochwolf|vps: yes seems im using bundler "RAILS_ENV=production bundle exec rake db:migrate"
<quebre>
so how do i add the mysql correctly ?
<epochwolf|vps>
quebre: add it to the Gemfile
<quebre>
in the "chiliproject" software ?
tatsuya_o has joined #ruby
<quebre>
epochwolf|vps: sorry im complete ruby noob
<quebre>
;/
<epochwolf|vps>
yeah
<quebre>
i have this in Gemfile:
<quebre>
platforms :mri_18, :mingw_18 do
<quebre>
group :mysql do
<quebre>
gem "mysql"
<quebre>
# gem "ruby-mysql"
<quebre>
end
<quebre>
so where do i add this mysql in Gemfile ?
<havenn>
Ownatik: Just being silly, but: system "cd `which <gem_name_here> | xargs dirname`; cd .."
dnyy has joined #ruby
jwang has joined #ruby
iocor has joined #ruby
burgestrand has joined #ruby
snearch has joined #ruby
kirun has joined #ruby
C0NNER has joined #ruby
justinmcp has joined #ruby
ben225 has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
Sailias has joined #ruby
mmokrysz has joined #ruby
<nim_>
is there any method to display a two dimentional array as a table?
sonkei has joined #ruby
linoj_ has joined #ruby
c0rn has joined #ruby
<Deele>
I have a server, that responds on queries, but responses from server. is handled by one specific function, how to make it possible, to make another function, that returns specific server response to query
eywu has joined #ruby
MarkDBlackwell has joined #ruby
<tommylom1ykins>
hmm
<tommylom1ykins>
Does ruby provide a class for manipulating directory paths?
<MarkDBlackwell>
A weird thing is happening, which I don't remember before (and it works fine without `print'): ruby -e"print ([1,2].each do end)" is giving me, `syntax error, unexpected keyword_do_block, expecting ')' '. Should I reboot Windows?
<rippa>
manipulating how?
nacengineer has joined #ruby
cyri_ has joined #ruby
sorin has joined #ruby
<MarkDBlackwell>
tommylom1ykins, probably, check out `require "pathname"'.
<tommylom1ykins>
rippa: Basically I want something that will gibe me "dir/subdir" from the string "dir" and "subdir", without doing "#{dir}/#{subdir}"
<rippa>
File#join
t0mmyvyo has joined #ruby
mmokrysz has quit [#ruby]
<tommylom1ykins>
aha
<tommylom1ykins>
thanks
<quebre>
how do i remove a gem? for installing its 'gem install [gemname]'
<nlew>
quebre: `gem uninstall [gemname]`, look at `gem help commands`
a1ph4g33k has joined #ruby
<MarkDBlackwell>
Two sets of parentheses makes it work! But why? print (([1,2].each do end))
cdabba has joined #ruby
trivol has joined #ruby
a1ph4g33k has joined #ruby
<MarkDBlackwell>
It's the same all the way back to Ruby 1.8.6-p0, BTW.
cableray has joined #ruby
<MarkDBlackwell>
Including 1.8.7-p357, 1.9.2-p290 and 1.9.3-p0.
<JonnieCache>
MarkDBlackwell: you might want to try #ruby-lang which is the channel for the actual ruby interpreter
<MarkDBlackwell>
JonnieCache, thanks! :)
rushed has joined #ruby
twoism has joined #ruby
saurb has joined #ruby
Sailias has joined #ruby
baroquebobcat has joined #ruby
moshef has joined #ruby
nacengineer has joined #ruby
<moshef>
how do I get 5 random elements from array? (ruby 1.8.7)
voodoofish430 has joined #ruby
bjensen has joined #ruby
<JonnieCache>
moshef: a.shuffle[0..5]
<JonnieCache>
but thats quite inefficient
<JonnieCache>
oops 0..4
<moshef>
exactly, because it goes on the entire array
<MarkDBlackwell>
JonnieCache, BTW, they helped me there, and the rule is good for here, too: Don't put spaces before parentheses, even after print (or p,puts,putc). :)
kmurph79 has joined #ruby
MarkDBlackwell has quit [#ruby]
cdabba has joined #ruby
marvin_ has joined #ruby
c0rn has joined #ruby
Sailias has joined #ruby
Axsuul has joined #ruby
Axsuul has joined #ruby
chimkan_ has joined #ruby
hooper_ has joined #ruby
nanderoo has joined #ruby
adamkittelson has joined #ruby
<cdabba>
anyone here give me advice for installing rvm? i foollowed the install instructions but its telling me type rvm is a hash (and it should be function)
<a1ph4g33k>
( followed by adding the appropriate line to your shell profile. )
bbttxu_ has joined #ruby
<cdabba>
so the instructions say to add the line to .bash_profile, but looking at .bash_profile, that is the only entry. what else could the shell profile be named, or,might that benormal?
<a1ph4g33k>
.profile some times
<a1ph4g33k>
for me, I add to .zshenv since I use zsh instead of bash
<JonnieCache>
.profile .bashrc
burgestrand has joined #ruby
<JonnieCache>
on some linuxes there is /etc/profile.d which is nice
zomgbie has joined #ruby
<JonnieCache>
it doesnt matter where you put it as long as it gets run on login
<JonnieCache>
also theres /etc/profile
<a1ph4g33k>
... just be careful with /etc/profile.d ( or /etc/zsh/zshenv ) because those will get run by all users on the system using those shells, even if they haven't installed rvm.
skrewler has joined #ruby
<a1ph4g33k>
but, the code does check for rvm installation before doing anything.
theRoUS has joined #ruby
Azure has joined #ruby
fayimora has joined #ruby
phantomfakeBNC has joined #ruby
shellox has quit [#ruby]
trend has joined #ruby
Sliker has joined #ruby
<regedarek>
Hi, how can i test in console simple gem.My gem is here -> https://github.com/regedarek/soup-client When i run `irb lib/soup-client.rb` i get LoadError: no such file to load -- soup-client/version
nowthatsamatt has joined #ruby
nowthatsamatt has quit [#ruby]
<regedarek>
is possible to set this wihout rewriting gem ??
<alaska>
Still fairly new to Ruby and attempting to adjust my CPANny workflow. When I 'gem install somegem' and I want to check out the rdoc for it, how do I do so. Often, the documentation is not indexed by the gem name.
<gift>
try using strict
ephemerian has joined #ruby
<gift>
:>
gabeh_ has joined #ruby
ben225 has joined #ruby
marvin_ has joined #ruby
Phlogistique has joined #ruby
<Phlogistique>
Hi
Faris has joined #ruby
Faris has quit [#ruby]
<Phlogistique>
is there a non-ugly way to write class A; class <<self; attr_accessor :a; end; @a = "foo"; end?
<Phlogistique>
(this feels a bit unnatural; not sur if doing it right)
<a1ph4g33k>
Phlogistique: what are you trying to do?
<a1ph4g33k>
just add an attribute?
<a1ph4g33k>
class A ; attr_accessor :a ; @a = "foo" ; end
oooPaul has joined #ruby
<Phlogistique>
I have a class that is a kind of translator between one format and another; I'd like to be able to globally set options to this translator
<Phlogistique>
I would have thought that class A ; attr_accessor :a ; @a = "foo" ; end creates an accessor in the _instances_ of a
<Phlogistique>
*_instances_ of A
gabeh has joined #ruby
ribo has joined #ruby
<a1ph4g33k>
ah.
<ribo>
anyone here use the amazon-ec2 gem?
<oooPaul>
Phlogistique, you are correct.
dv_ has joined #ruby
<oooPaul>
The problem is that attr_accessor also saves those values on the instances.
<oooPaul>
@a defined in the scope of the class itself is not the same as @a in the scope of an instance.
Sailias has joined #ruby
<Phlogistique>
yes; I want it in the class
<Phlogistique>
basically, I want to be able to do A.a = "foo"
<oooPaul>
Right.
jamw has joined #ruby
<Phlogistique>
now that I think about it, maybe a less-ugly way to solve the same problem would be
<oooPaul>
So, you could define an instance method that does self.class.instance_eval{@a} to get back the value.
<Phlogistique>
to define the class as class A; @a = "foo"; end
<Phlogistique>
and to tell users who want to change the option to do class A; @a = "bar"; end in their own code
<Phlogistique>
oooPaul: why an instance method? I don't want to
<oooPaul>
class A; @a = 42; def foo; self.class.instance_eval{@a}; end; end
<Phlogistique>
get the value from an instance
<oooPaul>
Why use a class, then? Not a module?
momo_ has joined #ruby
<oooPaul>
I guess I'm confused. I thought you wanted to have a global setting on the class that all of the instances of that class could reference?
<Phlogistique>
because I also want instances of my class
<oooPaul>
Okay, so set a class method to return @a.
<Phlogistique>
oooPaul: yes
<Phlogistique>
I know that
<Phlogistique>
I was asking how to do that in a non-ugly way
<alaska>
I think it might be a bug in RDoc for 1.9.3-preview1
<alaska>
Am going to try it with rc1
<csavola>
alaska: why are you still using a preview for 1.9.3?
<alaska>
Didn't actually know which was the best to use.
nyuszika7h has joined #ruby
<csavola>
alaska: p0 has been out for quite some time
<shadoi>
the YARD stuff is for 1.9.2
<alaska>
I did not know the significance of [-p0]
<a1ph4g33k>
shadoi: thanks for the heads up ... hadn't noticed that.
hmans has joined #ruby
<csavola>
alaska: the -p is the patch level of the ruby... think they consider 0 "experimental" if I remember correctly but it is better than a preview
Revernd has quit [#ruby]
havenn has joined #ruby
<shadoi>
it simply means it's the first release.
<shadoi>
aka 1.9.3.0
<alaska>
Ahaa. Still getting a feel for its versioning system.
adac has joined #ruby
<alaska>
See, that would have been better
<adac>
how do i get the first key of a hash?
<alaska>
adac, there is no "first" key
<shadoi>
adac: hashes aren't ordered.
<alaska>
unless you want it sorted
<csavola>
shadoi: they are ordered in 1.9.2+
<adac>
alaska, i did sort it like that: @images_hash = @images_hash.sort{|a,b| b[1]<=>a[1]}
Faris1 has joined #ruby
<a1ph4g33k>
hash.keys.first ( random key in <1.9.3, first inserted key in >=1.9.3 )
<shadoi>
csavola: ah yeah I forgot they made it insertion ordered.
<shadoi>
csavola: still, it's a bad thing to assume IMO, can get confusing.
MasterIdler has joined #ruby
<adac>
cool, thank you guys!
<oooPaul>
Cool, 'rvm docs generate' fixed my ri problems. :)
mengu has joined #ruby
<csavola>
shadoi: agreed. a default implementation should not order it imo
<alaska>
hash.keys.sort[0] if you mean "first" alphabetically
daniel_hinojosa has joined #ruby
<adac>
a1ph4g33k, that is what i get: undefined method `keys' for #<Array:0x00000002934048> ...how can that be... @images_hash supposed to be a hash
<alaska>
adac: you need to use "image_hash" in the block
<alaska>
not "hash"
<alaska>
er, "images_hash"
<alaska>
or whatever you've called it.
<alaska>
You're basically saying "sort the keys of hash foo by comparing the values each key points to rather than the key itself"
luxurymode has joined #ruby
booginga has joined #ruby
<adac>
alaska, perfect! thank you a whole lot!
momo_ has joined #ruby
zomgbie has joined #ruby
snearch has joined #ruby
visof has joined #ruby
visof has joined #ruby
yekta has quit [#ruby]
Sliker has joined #ruby
<shadoi>
regedarek: usually the library you're using for HTTP will include a "status" accessor method, or a way to get the raw headers.
Faris has quit [#ruby]
cableray has joined #ruby
<shadoi>
I see, you're using soup, and it's hiding it all from you.
aers has joined #ruby
<regedarek>
i have require "net/http"
davidpk has joined #ruby
momo_ has joined #ruby
startling has joined #ruby
<startling>
when you instantiate a class, the body of the class definition gets run with `self` pointing to the new instance, correct?
<startling>
so it's sort of similar to python's `__init__` method?
<csavola>
startling: the body of the class is run on load only
<csavola>
startling: the #initialize method will be run though
stephans has joined #ruby
<startling>
ah, I think I understand. so the methods are class methods, then?
kf8a has joined #ruby
<csavola>
startling: if the method definition starts with self (e.g def self.foo) it is a class method otherwise (given a few edge cases) it is an instance method
amacgregor has joined #ruby
<startling>
weird. is `self` the class or the instance?
Sailias has joined #ruby
<csavola>
startling: Think of the body of the class as just code that is executed. So when the parser first loads the class and encounters a plain "def" it will be an instance method. If the parser encounters "def self." self is the class definition itself so it goes on the object that represents the class
<startling>
ah, that makes perfect sense. thanks!
BrokenCog has quit [#ruby]
BBonifield has quit [#ruby]
Faris1 has joined #ruby
dennda has quit ["Thanks"]
Faris1 has quit [#ruby]
eignerchris_ has joined #ruby
momo_ has joined #ruby
<alaska>
a1ph4g33k: looks like it was indeed a problem with preview1
<alaska>
FYI
DrShoggoth has joined #ruby
<alaska>
`ri CSV` works fine now.
josx has joined #ruby
QKO has joined #ruby
fayimora has joined #ruby
nari has joined #ruby
yfeldblum has joined #ruby
randym has joined #ruby
<startling>
is there a way to print the representation of an object? I'm debugging so I'd rather have `[1, 2, 3]` than `1\n2\n3\n` and `"hello, world"` rather than just `hello world`.