brunocoelho has quit [Remote host closed the connection]
<apeiros_>
or require 'active_support/core_ext'; str.underscore
<apeiros_>
bnagy: if you use (?: instead of (, you can leave the flatten away
<Tasser>
apeiros_, I think active_support/core_ext/string is sufficient
<apeiros_>
Tasser: probably, yeah
<apeiros_>
I'm lazy :)
<bnagy>
actually the brackets are left over from trying split, they shouldn't be there at all, nor should the flatten
<banisterfiend>
bnagy: can u fix it up sexy for me
<bnagy>
.scan(/[A-Z][a-z]+/).map(&:downcase).join('_') but I wouldn't call it sexy
brushbox has joined #ruby-lang
<Tasser>
bnagy, not enough (.)(.)?
<bnagy>
and it's broken for things like YAMLStringCreator
<bnagy>
Tasser: :D
umttumt has quit [Remote host closed the connection]
umttumt has joined #ruby-lang
<apeiros_>
it's also broken for "A_B_C_stuff"
<apeiros_>
# => "" :)
chendo_ has joined #ruby-lang
<kyrylo>
The given string is a camelCase string.
<banisterfiend>
no it's CamelCase
<Tasser>
looks more like CamelCase to me
<banisterfiend>
it's a module name i want to convert to a gem name
<banisterfiend>
what's a name that combines the idea of an owner and receiver? i have a method that returns the receiver (in case of singleton method) or owner (in case of normal methods) but i cant thin of a ne=ame for it
brushbox has quit [Quit: Leaving.]
<outsmartin>
banisterfiend: producre consumer?
yugui_zzz is now known as yugui
<banisterfiend>
i just called it method_host() in the end
postmodern has quit [Quit: Leaving]
piyush has joined #ruby-lang
gsav has quit [Ping timeout: 255 seconds]
<dkannan>
banisterfiend: what is the diff btw owner and receiver. if i include a module M in Class A. then A is the receiver but M is the owner ?
<banisterfiend>
dkannan: no
<banisterfiend>
dkannan: class A; def bing; end; end; alpha = A.new a.bing ; a is the receiver of bing, A is the owner
<banisterfiend>
alpha*
<banisterfiend>
u get it
<Mon_Ouie>
The receiver is the object you call a method on obj in (obj.foo), the owner is the class/module that defines the method
<Mon_Ouie>
(obj in obj.foo)*
vesan_ has quit [Remote host closed the connection]
vesan has joined #ruby-lang
<dkannan>
ok
<banisterfiend>
dkannan: say "thank you very much sirs" not just 'ok', 'ok' hurts our feelings
<banisterfiend>
;)
<dkannan>
:-)
bastilian has quit [Quit: Leaving...]
<dkannan>
much obliged, gracias :-)
umttumt has quit [Remote host closed the connection]
gsav has joined #ruby-lang
<dkannan>
banisterfiend: why are u writing such a function ? what happens of the singleton method is up the inheritance/module chain ?
<dkannan>
r/of/id
yugui is now known as yugui_zzz
<banisterfiend>
dkannan: because i want a module with a name, if possible (though still not guaranteed); and a singleton method's receiver is more likely to have a name than its owner
umttumt has joined #ruby-lang
<banisterfiend>
in the case of singleton methods for classes/modules
cynosure has quit [Ping timeout: 252 seconds]
cynosure has joined #ruby-lang
<dkannan>
banisterfiend: ah ok. maybe drop into the code a do a defined? or a method ?
vesan has quit [Read error: Connection reset by peer]
<dkannan>
banisterfiend: you can call it father/mother/cousin :-) like in an ancestory tree
vesan_ has joined #ruby-lang
<dkannan>
banisterfiend: find_method also makes sense
<banisterfiend>
thx
<dkannan>
banisterfiend: or even find_closest/next_method
A124 has quit [Quit: Leaving.]
jimmy1980 has joined #ruby-lang
bastilian has joined #ruby-lang
countdigi has joined #ruby-lang
dalekurt has joined #ruby-lang
qwerxy has quit [Quit: offski]
dalekurt has quit [Quit: I'll be back!]
dr0id has left #ruby-lang [#ruby-lang]
A124 has joined #ruby-lang
jxie has quit [Quit: leaving]
umttumt has quit [Remote host closed the connection]
ttilley is now known as ttilley_off
dreieins has quit [Quit: and away]
A124 has quit [Quit: Leaving.]
workmad3 has joined #ruby-lang
umttumt has joined #ruby-lang
igaiga has quit [Remote host closed the connection]
workmad3 has quit [Read error: Operation timed out]
<Mon_Ouie>
I think it's false when the two nans aren't the same object (i.e. different object)
<Mon_Ouie>
The constant will always give you the same object
Bwild has quit [Quit: leaving]
<raz>
ahh!
<raz>
that explains why my padding NANs return true and the unpacked ones false
gsav has quit [Ping timeout: 250 seconds]
<raz>
thx, this was starting to give me a headache ;)
<Mon_Ouie>
And I think it does that to avoid infinite recursion
<Mon_Ouie>
(e.g. when an array contains itself)
Bwild has joined #ruby-lang
<raz>
well, i was surprised that [Float::NAN] == [Float::NAN] would evaluate to true, but then figured that might be the ruby way
<raz>
under that false premise i was thrown back when the deserialized NANs behaved differently
<raz>
but your explanation makes sense
<raz>
it's always the little things :)
<apeiros_>
Mon_Ouie: doesn't seem to be the reason…
<apeiros_>
a = Float::NAN; a == a # => false
<apeiros_>
that seems like a bug, given that Array#== is supposed to test == on each object, I really wonder what's going on…
<apeiros_>
maybe Array#== does an invalid optimization, testing for .equal? first
<apeiros_>
(probably using a comparison of the VALUE)
qwerxy has quit [Quit: offski]
<raz>
fwiw, the array-behavior was actually convenient in rspec ;)
<apeiros_>
an array containing itself is not an issue either, since Array#== probably first tests for equal? (on the argument, not each element as I suspect to be the reason for the bug)
<raz>
but you are right, it actually doesn't seem to make sense.
fayimora has quit [Ping timeout: 240 seconds]
<Mon_Ouie>
a, b = [], []; a << b; b << a; a == b # => true
xtagon has joined #ruby-lang
<apeiros_>
Mon_Ouie: hm? yes? that's expected…
<apeiros_>
ah, you mean an equal? test wouldn't work
fayimora has joined #ruby-lang
<Mon_Ouie>
Yeah
gsav has joined #ruby-lang
fayimora_ has joined #ruby-lang
<apeiros_>
Mon_Ouie: well then, seen hash
fayimora_ has quit [Read error: Connection reset by peer]
fayimora has quit [Ping timeout: 264 seconds]
Axsuul has joined #ruby-lang
misham has quit [Ping timeout: 265 seconds]
NOKAH has joined #ruby-lang
Hakon|mbp has quit [Read error: Connection reset by peer]
NOKAH has quit [Remote host closed the connection]
Hakon|mbp has joined #ruby-lang
ryanf has quit [Ping timeout: 255 seconds]
Axsuul has quit [Read error: Connection reset by peer]
Axsuul has joined #ruby-lang
nofxx has quit [Remote host closed the connection]
bastilian has quit [Quit: Leaving...]
solars has joined #ruby-lang
Hakon|mbp has quit [Remote host closed the connection]
Hakon|mbp has joined #ruby-lang
ruurd has quit [Quit: Leaving...]
ruurd has joined #ruby-lang
cdt has joined #ruby-lang
bastilian has joined #ruby-lang
outsmartin has quit [Quit: Leaving.]
ryanf has joined #ruby-lang
coryf has joined #ruby-lang
Guest10243 has quit [Remote host closed the connection]
Hakon|mbp has quit [Remote host closed the connection]
tonni_ has quit [Remote host closed the connection]
Hakon|mbp has joined #ruby-lang
asahi has joined #ruby-lang
t has joined #ruby-lang
t is now known as Guest53242
imajes has quit [Excess Flood]
imajes has joined #ruby-lang
toertore has joined #ruby-lang
mssola has quit [Quit: Konversation terminated!]
toretore has quit [Ping timeout: 272 seconds]
asahi has left #ruby-lang [#ruby-lang]
piyush has quit [Ping timeout: 244 seconds]
asahi has joined #ruby-lang
S2kx has joined #ruby-lang
<asahi>
if I have an array like, [[a,b], [c,d]], how can I find and access the child array whose first element is a?
S1kx has quit [Ping timeout: 252 seconds]
<ben_m>
assoc
<ben_m>
Is there a ruby eval bot in this channel?
<ben_m>
> [[1, 2], [3,4]].assoc 3
<ben_m>
asahi, like that :)
<asahi>
ben_m: I see. thanks. what if, I wanted to find by the second element?
<asahi>
would I have to use something else other than assoc?
<epitron>
man, assoc must be an ancient method... that's so weird
<epitron>
this feels like something you'd need before ruby had hashes :)
<ben_m>
Comes from Common Lisp I think
<ben_m>
At least Common Lisp has it and influenced Ruby, so there's that
<ben_m>
asahi, you'd have to write that yourself I guess :)
Hakon|mbp has quit [Remote host closed the connection]
Hakon|mbp has joined #ruby-lang
gsav has joined #ruby-lang
tonni has joined #ruby-lang
francisfish has quit [Remote host closed the connection]
francisfish has joined #ruby-lang
neocoin has quit [Remote host closed the connection]
Asher has quit [Quit: Leaving.]
sailias has joined #ruby-lang
oddmunds has quit [Ping timeout: 248 seconds]
daym0n has joined #ruby-lang
gsav has quit [Ping timeout: 264 seconds]
francisfish has quit [Ping timeout: 248 seconds]
Asher has joined #ruby-lang
<epitron>
"so far", eh?
<epitron>
does that mean you hit a block? :)
gsav has joined #ruby-lang
NOKAH has joined #ruby-lang
sailias has quit [Ping timeout: 265 seconds]
banisterfiend has quit [Read error: Connection reset by peer]
jperry2 has joined #ruby-lang
macmartine has quit [Quit: macmartine]
Hakon|mbp has quit [Ping timeout: 272 seconds]
tomb_ has quit [Quit: Computer has gone to sleep.]
imperator has quit [Ping timeout: 264 seconds]
tomb_ has joined #ruby-lang
banisterfiend has joined #ruby-lang
macmartine has joined #ruby-lang
ruurd has quit [Quit: Leaving...]
gsav has quit [Ping timeout: 245 seconds]
gsav has joined #ruby-lang
imperator has joined #ruby-lang
jperry2 has quit [Quit: jperry2]
jaimef is now known as Ober
macmartine has quit [Quit: macmartine]
misham has joined #ruby-lang
solars has quit [Ping timeout: 265 seconds]
macmartine has joined #ruby-lang
macmartine has quit [Client Quit]
jarred has joined #ruby-lang
<jarred>
hi all
msaffitz has joined #ruby-lang
workmad3 has joined #ruby-lang
jperry2 has joined #ruby-lang
<jarred>
I'm getting "A JSON text must contain at least two octets! (JSON::ParserError)" when trying to parse JSON. I understand what the error message means, but I don't understand why it's happening. Here's how I write/read the JSON to/from the file https://gist.github.com/9a2733dfa7261e118efb. Any ideas?
gsav has quit [Ping timeout: 250 seconds]
qwerxy has joined #ruby-lang
<Mon_Ouie>
I don't know why you get this error, but do you have an actual reason to use JSON here?
<Mon_Ouie>
It seems you could just write/read the token itself
<jarred>
Yeah, this is true
<jarred>
I'll just do that
frem has quit [Quit: Farewell!]
fayimora has joined #ruby-lang
fayimora has quit [Client Quit]
misham has quit [Ping timeout: 245 seconds]
s0ra_h is now known as sora_h
ruurd has joined #ruby-lang
jperry2 has quit [Quit: jperry2]
ruurd has quit [Client Quit]
tbuehlmann has quit []
NOKAH has quit [Remote host closed the connection]
tallship has quit [Read error: Connection reset by peer]
tomb_ has joined #ruby-lang
brushbox has joined #ruby-lang
neocoin has joined #ruby-lang
nertzy has joined #ruby-lang
workmad3 has joined #ruby-lang
nertzy has quit [Client Quit]
nertzy has joined #ruby-lang
guns has joined #ruby-lang
neocoin has quit [Remote host closed the connection]
brushbox has quit [Quit: Leaving.]
Nekka has joined #ruby-lang
workmad3 has quit [Ping timeout: 264 seconds]
sebastia has quit [Quit: Leaving...]
guns has quit [Quit: guns]
cube526 has joined #ruby-lang
jperry2 has joined #ruby-lang
cube526 has quit [Client Quit]
seanstickle has joined #ruby-lang
ben_m has quit [Quit: Leaving]
ben_m has joined #ruby-lang
jperry2 has quit [Client Quit]
s0ra_h is now known as sora_h
akira989 has joined #ruby-lang
malias has joined #ruby-lang
S1kx has joined #ruby-lang
S1kx has joined #ruby-lang
S2kx has quit [Ping timeout: 244 seconds]
ryanf has joined #ruby-lang
naquad has quit [Excess Flood]
mistym has quit [Remote host closed the connection]
naquad has joined #ruby-lang
malias has quit [Remote host closed the connection]
daym0n has quit [Ping timeout: 245 seconds]
srbartlett has joined #ruby-lang
sora_h is now known as s0ra_h
misham has joined #ruby-lang
<rking>
jarred: The top level of a JSON object is always an array or object, so [] or {} is the shortest any JSON object could possibly be (that is, two bytes (aka octets))
misham has quit [Read error: Operation timed out]
s0ra_h is now known as sora_h
toertore has quit [Quit: Leaving]
Boohbah has quit [Ping timeout: 276 seconds]
retro|cz has quit [Ping timeout: 265 seconds]
retro|cz has joined #ruby-lang
<jarred>
That makes sense. The problem turned out to be when I was parsing JSON later in the file, one of the query string options was wrong, causing a 500 error
postmodern has joined #ruby-lang
banisterfiend has quit [Remote host closed the connection]
banisterfiend has joined #ruby-lang
Criztian has quit [Remote host closed the connection]
plusk has joined #ruby-lang
qwerxy has quit [Quit: offski]
qwerxy has joined #ruby-lang
wallerdev has quit [Quit: wallerdev]
dejongge has quit [Read error: Operation timed out]