<pabloh>
does anyone know if top level instance variables are file scoped?
headius has joined #ruby-lang
volty has joined #ruby-lang
Gunnar has joined #ruby-lang
replore has joined #ruby-lang
<drbrain>
pabloh: they are
<drbrain>
oh, I thought you said local, instance variables are shared since you're working on the same top-level instance
<injekt>
heh
<pabloh>
drbrain, ok thx, banisterfiend already told me at #ruby
<andrewvos>
oooh burn
<injekt>
global methods are throw into Object, yet ivars are not
<injekt>
also, cross posting is annoying
<pabloh>
injekt: err..., sry
<rue>
#ruby is annoying
<injekt>
especially somewhere as rude as ruby
<injekt>
oh here we go
<injekt>
dont start rue
<injekt>
every. single. time.
<andrewvos>
Now you got rue all pissed off
<injekt>
it's like he has a hilight on #ruby
<injekt>
so I've been using ST2 for about 2-3 hours now and I actually love it
<twelvechairs>
cross posting might be annoying, but it makes sense when there are two channels for the same thing....
<injekt>
this channel is official
<injekt>
the other is not, let's go and make a third one and post there too shall we?
<injekt>
it makes sense because they're all for the same thing
<injekt>
:D
<andrewvos>
hmm, sounds logical
<twelvechairs>
yes. however that channel regularly has nearly twice the number of people on it...
<deryldoucette>
but to most people #ruby would be the official in their mind. they don't know about #ruby-lang pere i'd wager
<injekt>
deryldoucette: pretty much exactly the only reason they get so many users
<andrewvos>
#lolruby
<deryldoucette>
injekt: i can't fault that logic
<andrewvos>
Why don't we all just go there?
<injekt>
yeah, we're closing #ruby-lang
<injekt>
just leave rue here
<deryldoucette>
just saying, i can see why they would think #ruby rather than #ruby-lang would be the 'official' channel.
<deryldoucette>
lol
<deryldoucette>
rue turn off the lights before you leave
<andrewvos>
hahahaha
<injekt>
deryldoucette: I agree
<twelvechairs>
Maybe it is sacrelidge to say this here, but why can't they just make #ruby the official channel? Surely the owners of the channels could talk to each other
<injekt>
tried that
<injekt>
(talking)
<andrewvos>
We lost 17 men that day
Karmaon has joined #ruby-lang
<injekt>
and a bot
<injekt>
RIP
<andrewvos>
OOh that remidns me I was setting up a bot for work!!
<deryldoucette>
Robots In Pieces?
* zenspider
pours a drink for his homies
<injekt>
deryldoucette: robots in #python
<injekt>
andrewvos: an irc bot?
<twelvechairs>
wow. sounds.... apathetic...
<deryldoucette>
quick get him! he said the P word!
<injekt>
uh oh!
* injekt
runs
<andrewvos>
injekt: yeah
<injekt>
zenspider: thank you for minitest
<zenspider>
injekt: my pleasure
<zenspider>
thanks for enjoying it
<andrewvos>
zenspider: Yah I second that, after fucking about for hours in a project that uses rspec today. Mocks *everywhere*
<andrewvos>
So many
<andrewvos>
So so many
<andrewvos>
And I have to work on it tomorrow
<andrewvos>
Right I'm going to sleep
<injekt>
andrewvos: what you using for it? :)
<drbrain>
I once asked "how can I be the ruby official person thingy for freenode"
<rue>
Weakling
<drbrain>
and a freenode staff member said "you need to get matz to sign off"
Indian has joined #ruby-lang
<andrewvos>
injekt: Using for what?
<drbrain>
and I said "I know matz!"
<injekt>
andrewvos: irc
<drbrain>
and I got laughed at
<injekt>
drbrain: lol
<drbrain>
so that was the end of that
<injekt>
wait that's not helping
<zenspider>
drbrain: so get matz to sign off on it
<injekt>
^
<rue>
drbrain: It's marginally easier now, FWIW
nilibanili has joined #ruby-lang
<rue>
I emailed -core recentlyish, but I don't think anyone ever responded to that
<andrewvos>
injekt: Uhh the ruby one I think.. or was it hubot?
<andrewvos>
Yeah hubot
<drbrain>
zenspider: they wouldn't tell me how that happened
<deryldoucette>
i haven't even played with it yet. nothing i'm doing requires it (yet)
<andrewvos>
deryldoucette: That's what she siad
<andrewvos>
said*
<deryldoucette>
heh
<andrewvos>
Wait didn't I say I was going to sleep?. Ok that's happening. Night
<deryldoucette>
later. my rottie is beggin me to play with her for a bit so.. i'm off too. Night
DEac- has joined #ruby-lang
<shevy>
rotten wife??
<andrewvos>
shevy: I was thinking that too
<zenspider>
god I love rsync 3
<cout>
zenspider: the movie?
<rue>
Straight to video
<andrewvos>
hahaha
MistyM has joined #ruby-lang
<deryldoucette>
lol, sometimes i think she thinks she is my rotten wife
<deryldoucette>
my rottweiler
QoQOoO has joined #ruby-lang
<cout>
rot while her what?
jtoy has joined #ruby-lang
QoQOoO has joined #ruby-lang
looopy has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
srbaker has joined #ruby-lang
ttilley has joined #ruby-lang
gix has joined #ruby-lang
andkerosine has joined #ruby-lang
ta8let has joined #ruby-lang
ta8let has quit [#ruby-lang]
SuperTaz_work has joined #ruby-lang
savage- has joined #ruby-lang
QoQOoO has joined #ruby-lang
rushed has joined #ruby-lang
shtirlic has joined #ruby-lang
macmartine has joined #ruby-lang
muzone has joined #ruby-lang
<andkerosine>
How to build the setter for a multi-dimensional array?
<andkerosine>
For instance, config['x']['y] = z
<andkerosine>
Without having to keep writing to the file after every change?
<theconartist>
don't write the file after every change?
<andkerosine>
It is necessary for proper functioning.
<theconartist>
but you just said you don't want to..?
<erikh>
who's on first?
<andkerosine>
I meant without doing it explicitly.
<andkerosine>
I'd like to create a setter that does the writing.
<theconartist>
well just make a method for it
<theconartist>
you could make the config a singleton so it's like config[x,y] = z; or something
andrewhl has joined #ruby-lang
bhrgunatha has joined #ruby-lang
<rue>
Multiple args withit [] is the best you can do, yes, or then you need to provide a proxy returned by #[], which implements #[]= as you need it to
bitrot has joined #ruby-lang
elux has joined #ruby-lang
neoesque has joined #ruby-lang
dv310p3r has joined #ruby-lang
andrewhl has joined #ruby-lang
tomzx has joined #ruby-lang
<andkerosine>
So, I would really like for it to work like this, and I think I'm really close: https://gist.github.com/1889771
WillMarshall has joined #ruby-lang
<andkerosine>
But the initialize is returning an empty hash.
<andkerosine>
If I write a load method that returns the hash, that works fine, but then I have to set @config to Config.new.load, which then doesn't let me assign to it later.
<lsegal>
you're not doing anything with your JSON.parse object
<lsegal>
andkerosine delegation is always preferred to inheritance
<erikh>
it probably has your fix in it -- it was only released a few days ago
gianlucadv has joined #ruby-lang
MistyM has joined #ruby-lang
<postmodern>
erikh, looks like it's still not fixed in 125
<erikh>
hum. phooey
<duckinator>
heftig: thanks for pointing out ruby_debug == $DEBUG before. i think i got it narrowed down to two possibilities causing $DEBUG to fix this bug, now :D
pp01bit has joined #ruby-lang
<lsegal>
bnagy the problem is it doesn't work perfectly. subclassing Hash will often lead you to edge cases where things don't work as expected unless you've overridden the entire Hash interface to delegate to the proper functionality, which is why composition is superior
<lsegal>
bnagy [], []= are the obvious ones, but then there is merge, merge!, update, replace, and more.
ramu3 has joined #ruby-lang
<duckinator>
I'm working safe ruby eval in pure ruby, and AFAIK the only bug is sleep() w/ no args hangs endlessly. https://github.com/duckinator/sicuro/blob/master/lib/sicuro/base.rb#L85-98 the Timeout.timeout{...} is where the evaluated code is ran. One of the behaviors in MRI changed when $DEBUG==true fixes this issue, but I can't track it down.
<hagabaka>
in https://blogs.kde.org/node/2679, at the end of extconf.rb it says 'exec "/opt/kde4/bin/moc #{$CPPFLAGS} testobject.h -o moc_testobject.cpp"'. It's not working for me because $CPPFLAGS is " $(DEFS) $(cppflags)". Was it meant to generate a line in the Makefile, instead of executing the command when running extconf.rb?
<bnagy>
lsegal: conflating 'some' with 'all' is not a great debating technique, imho. Yes, in some cases subclassing can give rise to issues. In many it works perfectly. In all it is shorter to write and easier to read.
<bnagy>
which is why it's used so much, including in the language itself
kitallis has joined #ruby-lang
<lsegal>
bnagy the point is that it's *preferred*; there are many other benefits to composition over inheritance that cover the other issues. i think you have the argument reversed. yes, sometimes you can get away with inheritance, but it's not often the preferred design choice.
dfr|mac has joined #ruby-lang
<bnagy>
I have no view on often versus sometimes versus rarely, only on 'never'
dfr|mac_ has joined #ruby-lang
<bnagy>
so I therefore declare this argument over :>
twittard has joined #ruby-lang
kitallis has joined #ruby-lang
gianlucadv has joined #ruby-lang
gokul has joined #ruby-lang
rohit has joined #ruby-lang
x0F_ has joined #ruby-lang
kitallis has joined #ruby-lang
woollyams has joined #ruby-lang
gnufied1 has joined #ruby-lang
bcardarella has quit [#ruby-lang]
yxhuvud has joined #ruby-lang
dc5ala has joined #ruby-lang
takaokouji has joined #ruby-lang
whatasunnyday has joined #ruby-lang
thone_ has joined #ruby-lang
rippa has joined #ruby-lang
leon1024 has joined #ruby-lang
whatasunnyday has joined #ruby-lang
amerine has joined #ruby-lang
Go has joined #ruby-lang
uniqanomaly has joined #ruby-lang
maek has joined #ruby-lang
<maek>
if I have an array of hashes, like so https://gist.github.com/1891181 how do I iterate over the hash values. I need the values of each has for a config line for hadoop.
<bnagy>
a.each {|hsh| hsh.each {|k,v| # do something} }
<bnagy>
you can store all your settings in a single hash, then
<maek>
ok ty, better and better
<maek>
was making a bunch of single element hashs
<maek>
obvious noob is obvious. thanks for the schooling
mytrile has joined #ruby-lang
<bnagy>
no worries
takaokouji has joined #ruby-lang
ostapbender has quit [#ruby-lang]
twelvechairs has joined #ruby-lang
mytrile has joined #ruby-lang
alim has joined #ruby-lang
brownies has joined #ruby-lang
kitallis has joined #ruby-lang
brianpWins has joined #ruby-lang
mytrile has joined #ruby-lang
mytrile has joined #ruby-lang
mytrile_ has joined #ruby-lang
mytrile has joined #ruby-lang
bhrgunatha has joined #ruby-lang
tla has joined #ruby-lang
Indian has joined #ruby-lang
mytrile has joined #ruby-lang
dfr|mac has joined #ruby-lang
gianlucadv has joined #ruby-lang
bjensen has joined #ruby-lang
Asher1 has joined #ruby-lang
mytrile has joined #ruby-lang
solars has joined #ruby-lang
Asher has joined #ruby-lang
frangiz has joined #ruby-lang
<hagabaka>
how can I define a module function in a C extension, so that I call it with TheModule.the_method?
<hagabaka>
oh rb_define_singleton_method
workmad3 has joined #ruby-lang
<cout>
yep
cyri_ has joined #ruby-lang
<hagabaka>
how can I return a ruby string from a const char* in an extension?
riffraff has joined #ruby-lang
d3vic3 has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
<yorickpeterse1>
Morning
<lsegal>
hagabaka rb_str_new2(), though you may want to add an encoding
<cout>
hagabaka: rb_str_new2(str)
<yorickpeterse1>
Morning
yorickpeterse1 has joined #ruby-lang
<yorickpeterse>
Sorry for that, that was a failing up key :)
pp01bit has joined #ruby-lang
<hagabaka>
thanks
Banistergalaxy has joined #ruby-lang
roadkith has joined #ruby-lang
<tla>
can anyone explain the magic of ruby's _ ?
gix has joined #ruby-lang
bjensen has joined #ruby-lang
tekin has joined #ruby-lang
<hagabaka>
what am I doing wrong in http://codepad.org/HKQQ36II ? getting In function ‘void Init_QuasselTypes()’: quassel_types.cpp:17:73: error: invalid conversion from ‘VALUE (*)(VALUE, VALUE) {aka long unsigned int (*)(long unsigned int, long unsigned int)}’ to ‘VALUE (*)(...) {aka long unsigned int (*)(...)}’ [-fpermissive]
zmack has joined #ruby-lang
zmack has joined #ruby-lang
vmoravec has joined #ruby-lang
<erikh>
hagabaka: I suspect it's something with C++
<hagabaka>
values are assigned to block arguments, so it's the same idea, to throw away those last two elements
<rippa>
sort_by do |(host, location)|
<rippa>
would work too
<rippa>
or sort_by do |(host, location, *)|
<rippa>
what's fun is
<rippa>
if you do |(host, location, derp, derp)|
<rippa>
ruby complains about repeated argument
<rippa>
but with _, _ it works
<rippa>
so it's a special case
<tla>
thanks
csherin has joined #ruby-lang
EvilJStoker_ has joined #ruby-lang
rohit has joined #ruby-lang
virunga has joined #ruby-lang
banisterbaby has joined #ruby-lang
<banisterbaby>
can anyone think of a way to determine whether a proc takes a block?
<banisterbaby>
i.e if it was defined as: proc { |&block|
EvilJStoker_ has joined #ruby-lang
Wardrop has joined #ruby-lang
havenn has joined #ruby-lang
<rue>
Hm, maybe you could round-trip it?
<rue>
Although apparently #parameters shows it so you don't need to
<banisterbaby>
rue: i need to support 1.8 though what did u mean by round-trip it, eero?
<rue>
Stupid 1.8
<rue>
banisterbaby: You could just detect 1.8 and hardcode it to false
<banisterbaby>
rue: Yeah
futurechimp has joined #ruby-lang
virunga has joined #ruby-lang
workmad3 has joined #ruby-lang
<andrewvos>
hahaha
<andrewvos>
Sounds legit
daglees has joined #ruby-lang
daglees has joined #ruby-lang
QoQOoO has joined #ruby-lang
<hagabaka>
is there something like p() in C extensions?
<rue>
hagabaka: Sure, #p
<hagabaka>
how do I call it in C code?
<rue>
(You can always rb_funcall(), but I think there's an rb_inspect(), too.)
<hagabaka>
what object do I pass to rb_funcall?
<shevy>
the pony object
<shevy>
VALUE arr;
<shevy>
arr = rb_iv_get(self, "@arr");
<shevy>
rb_funcall(arr, id_push, 1, obj);
<hagabaka>
but isn't p defined for Kernel?
<shevy>
obj is passed into the function
<shevy>
oh I dont know much about p
<hagabaka>
hmm rb_mKernel
tekin has joined #ruby-lang
<banisterbaby>
hagabaka: rb_p
<hagabaka>
ah, thanks
QaDeS has joined #ruby-lang
<hagabaka>
does RSTRING_PTR give the const char* of the string?
<banisterbaby>
hagabaka: Yeah
tekin has joined #ruby-lang
<tla>
another question: |foo,bar| vs |(foo,bar)| ?
<rippa>
tla: second splits array
vmoravec has joined #ruby-lang
<tla>
rippa: ah, thanks
postmodern has joined #ruby-lang
bosie has joined #ruby-lang
twelvechairs has joined #ruby-lang
havenn has joined #ruby-lang
chendo has joined #ruby-lang
Mon_Ouie has joined #ruby-lang
countskm has joined #ruby-lang
EvilJStoker has joined #ruby-lang
woollyams has joined #ruby-lang
m3nd3s has joined #ruby-lang
rippa has joined #ruby-lang
apeiros_ has joined #ruby-lang
codewrangler has joined #ruby-lang
woollyams has joined #ruby-lang
mytrile has joined #ruby-lang
<nofxx_>
hehe ~40 min for a big leap in unix time.... 1330000000
woollyams has joined #ruby-lang
rohit has joined #ruby-lang
<Wardrop>
Would anyone be able to explain why in my code, referring to the constant Allocation works fine, but using const_get(:Allocation) fails?
<Wardrop>
I've resorted to using eval(const_name) to lookup the constant, but I don't understand why const_get is not working?
stamina has joined #ruby-lang
<rue>
You're trying to get it in the wrong place, maybe?
<rue>
Need codes
<apeiros_>
Wardrop: const_get == self.const_get, self should be the module that contains Allocation
<Wardrop>
But shouldn't it lookup with inheritance, which is set to true by default. So if the constant I'm looking for is defined in the same module, shouldn't it find it.
chendo has joined #ruby-lang
<Wardrop>
I'm calling const_get from a Padrino controller (if you're familiar with the framework). The controller is defined as a block which is then instance_eval'd against the web application object. I can imagine that with the instance_eval, const_get may be getting screwed up.
<banisterbaby>
Wardrop: ensure that you're calling const_get on the correct object then
<banisterbaby>
pass in an explicit receiver
<banisterbaby>
use*
gokul has joined #ruby-lang
Oloryn_lt1 has joined #ruby-lang
<Wardrop>
I'll use the module the constant lives in then. E.g. Tombstone.const_get(:Allocation). It's just unusual how the lookup works fine if Allocation is referenced directly. I wonder if it's to do with block scoping. Allocation exists in-scope where the block is defined, but is out of scope where the block is instance_eval'd.
<Wardrop>
I guess constants are resolved when the block is defined, where as #const_get resolves constants when the block is invoked.
<Wardrop>
That's probably what's happening.
<andrewvos>
What's going on here?
<rue>
Where's my horse?
<andrewvos>
Who are all these people?
bjensen has joined #ruby-lang
t0h has joined #ruby-lang
voker57 has joined #ruby-lang
rohit has joined #ruby-lang
slyphon has joined #ruby-lang
vmoravec has joined #ruby-lang
diegoviola has joined #ruby-lang
cesario has joined #ruby-lang
Wardrop has joined #ruby-lang
niklasb has joined #ruby-lang
rshackleford has joined #ruby-lang
bosie has joined #ruby-lang
havenn has joined #ruby-lang
zmack_ has joined #ruby-lang
QaDeS has joined #ruby-lang
Indian has joined #ruby-lang
Austin__ has joined #ruby-lang
nilibanili has joined #ruby-lang
zmack has joined #ruby-lang
jasiek has joined #ruby-lang
Mon_Ouie has joined #ruby-lang
publicvoid has joined #ruby-lang
tommyvyo has joined #ruby-lang
riffraff has joined #ruby-lang
gnufied has joined #ruby-lang
rippa has joined #ruby-lang
tcurdt has joined #ruby-lang
malev has joined #ruby-lang
willdrew has joined #ruby-lang
malev has joined #ruby-lang
<TTilus>
rue: now that was john wayne, right?
fayimora_ has joined #ruby-lang
<rue>
Close, George Carlin.
anthony has joined #ruby-lang
fayimora has joined #ruby-lang
MistyM has joined #ruby-lang
<andrewvos>
Wow, I see there has been quite the conversation in my absence
* andrewvos
joins #ruby
retro|cz has joined #ruby-lang
daniel has joined #ruby-lang
robbrit has joined #ruby-lang
awacs has quit [#ruby-lang]
workmad3_ has joined #ruby-lang
bhrgunatha has joined #ruby-lang
jxie has joined #ruby-lang
<ddfreyne>
why #ruby?
mgraham has joined #ruby-lang
pemeon has joined #ruby-lang
gjaldon has joined #ruby-lang
wyhaines has joined #ruby-lang
seanstickle has joined #ruby-lang
<heftig>
ddfreyne: because bigger
sockmonk has joined #ruby-lang
Sailias_ has joined #ruby-lang
gongo has joined #ruby-lang
ave_ has joined #ruby-lang
tomzx has joined #ruby-lang
enebo has joined #ruby-lang
jxie has joined #ruby-lang
bjensen has joined #ruby-lang
tekin has joined #ruby-lang
slyphon has joined #ruby-lang
tbuehlmann has joined #ruby-lang
crazy_boy has joined #ruby-lang
dfr|mac has joined #ruby-lang
neoesque has joined #ruby-lang
Spooner has joined #ruby-lang
JEG2 has joined #ruby-lang
solars has joined #ruby-lang
dv310p3r has joined #ruby-lang
pp01bit has joined #ruby-lang
leonL has joined #ruby-lang
adambeynon has joined #ruby-lang
mistym has joined #ruby-lang
tcurdt has quit [#ruby-lang]
Slackwise_ has joined #ruby-lang
leonL_ has joined #ruby-lang
ascarter has joined #ruby-lang
alim has joined #ruby-lang
optikalmouse has joined #ruby-lang
<optikalmouse>
how can I generate a class diagram for ruby/rails files?
rayners has joined #ruby-lang
<deryldoucette>
damn i know this one. there was a gem that did classes, gems, gem deps, ect.
<deryldoucette>
can not remember its name.
<deryldoucette>
optikalmouse: try checking through gem search graph -dr
<deryldoucette>
(description and check remote is the -dr)
<optikalmouse>
deryldoucette: so gem search --details --remote graph does the same thing?
<ave_>
railroad works for rails if thats any good
dous has joined #ruby-lang
<deryldoucette>
thats the long form of the same params, but yes. it searches rubygems.org for anything with graph in its gem name and returns it along with the description
bryancp has joined #ruby-lang
<deryldoucette>
optikalmouse: gem list ograph -dr something like that what you looking for?
<ave_>
there are a couple of patches you have to make to work with 1.9.2+ I think
<optikalmouse>
we're using ruby 1.8.x, and it's jruby in fact lol
<optikalmouse>
so I think it should be good? we'll see, I'm running it now...
<deryldoucette>
if thats not it, might want to fire off a tweet to @headius (he's head of jruby project) and see what he offers
dous_ has joined #ruby-lang
NARKOZ has joined #ruby-lang
darkf has joined #ruby-lang
<optikalmouse>
deryldoucette: it just seems to run the rails app and forgets about generating a diagram lol
futurechimp has joined #ruby-lang
<deryldoucette>
doh!
<optikalmouse>
there's a way to add it as a rake task but I'm not sure how that would help...
<Harzilein>
hmm
<Harzilein>
are there archives of the old rubygarden wiki?
codewrangler has joined #ruby-lang
Rabbitt has joined #ruby-lang
virunga has joined #ruby-lang
<shevy>
Harzilein probably on that thing that is called the internet archive (eh, I forgot the real name...)
outoftime has joined #ruby-lang
dejongge has joined #ruby-lang
imajes has joined #ruby-lang
<Rabbitt>
shevy: only saw part of your conversation but, sounds like you are referring to the way back machine? (www.waybackmachine.org)
jMCg has joined #ruby-lang
<jMCg>
Hello happy people o/~
<jMCg>
I'm wondering if anyone cann tell me what happens when I connect via Ldap::Conn to a host via SSL or StartTLS and the certificate is invalid (date, host, chain) -- it's not stated in the documentation.
<Harzilein>
yeah, i tried that. only problem is that it looks like the links werent very crawler friendly and it missed the page that is referenced (a draft on trying to get aop features into core/stdlib)
looopy has joined #ruby-lang
gnufied has joined #ruby-lang
gnufied1 has joined #ruby-lang
wyhaines has joined #ruby-lang
havenn has joined #ruby-lang
Slackwise has joined #ruby-lang
JohnBat26 has joined #ruby-lang
piglop has joined #ruby-lang
slyphon has joined #ruby-lang
heppy has joined #ruby-lang
slimfit has joined #ruby-lang
maek has quit [#ruby-lang]
looopy has joined #ruby-lang
kyrylo has joined #ruby-lang
kyrylo has joined #ruby-lang
piglop has joined #ruby-lang
dfr|mac has joined #ruby-lang
<shevy>
Rabbitt yeah I think that was it
ascarter has joined #ruby-lang
apeiros_ has joined #ruby-lang
workmad3 has joined #ruby-lang
<andrewvos>
Right, where is banister
malev_ has joined #ruby-lang
carlosgaldino has joined #ruby-lang
<cout>
why banister?
<shevy>
noone kisses better
<andrewvos>
hahaha
pogopolice has joined #ruby-lang
gokul has joined #ruby-lang
looopy has joined #ruby-lang
malev has joined #ruby-lang
SuperTaz_work has joined #ruby-lang
<whitequark>
shevy: wayback machine
<whitequark>
you know, the rubygarden was waaaay too long ago to survive
<whitequark>
I would suggest a slightly more horrible, but also working way to do what you want
<davidw>
I'm trying to do some define_methods that appear only in the current instance... and I'm a bit stumped
kitallis has joined #ruby-lang
<andkerosine>
whitequark: All config is still manually controlled by me, I just don't want File#write everywhere, so the lack of #merge! is a non-issue.
<whitequark>
andkerosine: wrap a hash inside your Config and freeze it. forward all requests from your Config with method_missing to that hash. catch RuntimeError "frozen hash", unfreeze it, repeat the request, save it and freeze it back
<whitequark>
have I mentioned I like perversions?
<andkerosine>
That... does sound a bit excessive.
<whitequark>
it's like 10 lines of code
<shevy>
whitequark tell me more about which perversions you like
<shevy>
also, I hate .freeze
<riffraff>
davidw, use define_method on the singleton class of the object
<davidw>
riffraff, class << self.....
<riffraff>
yup, if you don't have a singleton_class method handy
<riffraff>
class << obj; works anyway
<whitequark>
shevy: I dislike freeze, but only if it's applied on `self' in my instance context.
<whitequark>
otherwise it's fine. just like .immolate
<davidw>
riffraff, ok, I had gotten that far... the tricky bit is I'm trying to pass in different parameters. If this is defined, create these methods from these parameters (more or less)
<davidw>
ugh... this is a mess
amerine has joined #ruby-lang
looopy has joined #ruby-lang
havenn_ has joined #ruby-lang
csherin has joined #ruby-lang
<andkerosine>
whitequark: Too perverse, but good thought food.
<andkerosine>
I imagine I would have to take a route somewhere along those lines if I wanted to completely re-implement Hash with persistence, but I really just need a slightly tweaked []=.
<riffraff>
davidw, sample code please :) seems to me " def define_foo(obj,bar) unless obj.respond_to?(:foo); obj.singleton_class.send(:define_method, :foo) {code based on bar} end end" should fit but I guess it's not what you need
looopy has joined #ruby-lang
macmartine has joined #ruby-lang
butchanton has joined #ruby-lang
headius has joined #ruby-lang
heppy has joined #ruby-lang
coreydaley has joined #ruby-lang
<davidw>
ugh... got it to pass the tests...
<davidw>
but it's slow
<davidw>
hrm
aprescott has joined #ruby-lang
aprescott has quit [#ruby-lang]
<davidw>
ok, so how about this... how to have one method that I can 1) call to define some methods in a module, but also call to define some methods in an instance
<davidw>
whack-a-mole.... hit it ther and it pops up over there
bglusman has joined #ruby-lang
mgraham has joined #ruby-lang
jredville has joined #ruby-lang
<riffraff>
how about def pseudo_define(o,m,&b) (o.respond_to?(:define_method) ? o : o.singleton_class).send(:define_method, m, &b) end ?
<riffraff>
multiple definitions goes naturally
<riffraff>
but I'm wondering if whwt you want is get a Foo instance in which does not respond to :meth, define a method :meth for all Foo instances
<riffraff>
only, Foo is not a class but a module
<riffraff>
not sure which module though
achiu has joined #ruby-lang
ascarter has joined #ruby-lang
<mistym>
davidw: Not sure exactly what you're going for, but what about sending a block that's `instance_eval`ed in different contexts?
zerokarmaleft has joined #ruby-lang
achiu has joined #ruby-lang
<davidw>
hrm... it's difficult even to describe
<davidw>
let's see.... I have a class, with some methods that should be available in 'default' cases, but not in others. Creating those methods is sort of expensive (parsing a file), so I'd like to 1) create them inside a module, but 2) only include them in the instances that need them, so as not to pollute other instances
<apeiros_>
davidw: see Object#extend
slaytanic has joined #ruby-lang
Sailias_ has joined #ruby-lang
gianlucadv has joined #ruby-lang
twittard has joined #ruby-lang
<andkerosine>
apeiros_: Differences, if any, between Object#extend and include?
pemeon has joined #ruby-lang
<apeiros_>
andkerosine: for starters, that extend is on Object, include on Module
<apeiros_>
try "foo".include Bar
<andkerosine>
Hm.
<riffraff>
davidw, #extend seems the thing yup
<andkerosine>
I only ask because right now I've got a bunch of single-method modules that I'm using as mixins to only expose relevant functionality to my objects.
<andkerosine>
But I hate the way it looks.
<andkerosine>
But the objects are classes, so it seems like the most sensible way to go about it.
<apeiros_>
o0
<andkerosine>
...?
<andkerosine>
"my objects" was meant loosely, and I certainly could've gone with a better word.
heppy has joined #ruby-lang
slimfit has joined #ruby-lang
jredville has joined #ruby-lang
Faris has joined #ruby-lang
dfr|mac has joined #ruby-lang
jacobwg has joined #ruby-lang
m3nd3s has joined #ruby-lang
maek has joined #ruby-lang
<maek>
is it bad mojo to make a :SYMBOL all upper case?
<matled>
maek: well, convention is to use lower case and underscores.
bagratte has joined #ruby-lang
<maek>
matled: ty
slyphon has joined #ruby-lang
woollyams has joined #ruby-lang
<drbrain>
maek: it's not unheard of: ruby -e 'p Object.constants'
slyphon_ has joined #ruby-lang
<hagabaka>
yeah, it's more a convention about method/module names, than about symbols
rue has joined #ruby-lang
Sailias_ has joined #ruby-lang
<maek>
thanks
postmodern has joined #ruby-lang
robertcarter has joined #ruby-lang
tbuehlmann has joined #ruby-lang
JohnBat26 has joined #ruby-lang
gix has joined #ruby-lang
mistym has joined #ruby-lang
tla has joined #ruby-lang
joshkraemer has joined #ruby-lang
tekin has joined #ruby-lang
Faris has joined #ruby-lang
<Faris>
Hello, how could I read raw binary data from a file in ruby ?
<Faris>
I'm trying to do it with IO.read but it doesn't read bytes like 0x0D
<apeiros_>
File.read(path, 'wb:binary')
<apeiros_>
ah, wrong
<Faris>
rb ?
<apeiros_>
File.read(path, :encoding => 'binary')
<apeiros_>
yeah, that'd have been 2 mistakes :)
<Faris>
and that will also read 0x0D's ?
<Faris>
:)
<apeiros_>
it's File.open that takes the args like that.
<apeiros_>
yes
<Faris>
thank you !
<Faris>
so the 'rb' argument isn't really binary reading ?
<apeiros_>
given that 0x0d is \r, even without binary setting, it should be read…
<Faris>
it isn't in my case :(
<apeiros_>
Faris: partially, rb is for File.open, not File.read. the binary there is only for windows
<Faris>
oh ok
<apeiros_>
in windows you have text vs. binary mode. it's unrelated to the encoding of the file
<apeiros_>
it's only about how newlines should be treated
<apeiros_>
IMO a silly thing, but well, what do we expect… it's windows…
<Faris>
okey.
<Faris>
actually 0x0D's are read
<Faris>
but there's a 0D 0A sequence in which only 0A is read
<Faris>
using my old method
<apeiros_>
so you're on windows then?
<Faris>
I'll try yours..
<Faris>
nope
<Faris>
Linux
<apeiros_>
o0
<Faris>
the file was created under windows though
<apeiros_>
that's odd then… you sure it happens at read-time?
<apeiros_>
\r\n shouldn't be converted to \n anywhere but on windows…
<apeiros_>
(0d 0a == \r\n)
<Faris>
When I read the file with a hex editor under windows, I can see the \r \n
<Faris>
but when I read it with ruby on linux, it only reads \n
<heftig>
File.read("foo", mode: "rb") should work
<Faris>
okey
workmad3 has joined #ruby-lang
<heftig>
if it doesn't, the file might have been modified when you transferred it to your linux system
<heftig>
ftp does that.
<Faris>
ooh
<Faris>
that must be it
<Faris>
that culprit
<heftig>
make sure ftp uses BINARY mode and not ASCII mode for transfer