baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://gist.github.com | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby
bmurt has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<quuxman> although I'm unclear how to do that
Guest5068 has quit [Remote host closed the connection]
tpendragon has quit [Remote host closed the connection]
pastorinni has quit [Remote host closed the connection]
GodFather has quit [Ping timeout: 260 seconds]
alfiemax has joined #ruby
sytherax_ has quit [Read error: Connection reset by peer]
shinnya has joined #ruby
cagomez has quit [Remote host closed the connection]
ElFerna has joined #ruby
cagomez has joined #ruby
apeiros has quit [Ping timeout: 248 seconds]
sytherax_ has joined #ruby
alfiemax has quit [Ping timeout: 260 seconds]
shinnya has quit [Ping timeout: 245 seconds]
cagomez has quit [Ping timeout: 252 seconds]
<quuxman> `Foo.where(...)` is failing with an invalid field error
mikecmpbll has quit [Quit: inabit. zz.]
alfiemax has joined #ruby
ElFerna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sytherax_ has quit [Ping timeout: 256 seconds]
sytherax_ has joined #ruby
guacamole has joined #ruby
guacamole has joined #ruby
guacamole has quit [Changing host]
alfiemax has quit [Ping timeout: 252 seconds]
cagomez has joined #ruby
alex`` has quit [Ping timeout: 248 seconds]
cagomez has quit [Ping timeout: 252 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
t0xik has quit [Quit: Connection closed for inactivity]
rivalomega has quit [Remote host closed the connection]
karapetyan has joined #ruby
cagomez has joined #ruby
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
karapetyan has quit [Ping timeout: 260 seconds]
lxsameer has quit [Ping timeout: 260 seconds]
alfiemax has joined #ruby
cagomez has quit [Ping timeout: 252 seconds]
alfiemax has quit [Ping timeout: 245 seconds]
ramfjord has quit [Ping timeout: 260 seconds]
ElFerna has joined #ruby
AndroUser has joined #ruby
harrycs has quit [Ping timeout: 256 seconds]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
harrycs has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 245 seconds]
cagomez has joined #ruby
AndroUser is now known as lowerlight
cagomez has quit [Ping timeout: 245 seconds]
lowerlight has quit [Quit: AndroIRC - Android IRC Client ( http://www.androirc.com )]
AndroUser has joined #ruby
AndroUser has quit [Client Quit]
giraffe has joined #ruby
lowerlight has joined #ruby
giraffe is now known as Guest29863
tpendragon has joined #ruby
lowerlight has quit [Client Quit]
lowerlight has joined #ruby
lowerlight is now known as help
help is now known as Guest49521
Guest49521 has quit [Client Quit]
bmurt has joined #ruby
catbusters has quit [Quit: Connection closed for inactivity]
Sembei has quit [Ping timeout: 245 seconds]
MyMind has joined #ruby
ElFerna has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
noobineer has quit [Ping timeout: 260 seconds]
cyberg has quit [Quit: Leaving]
sumobob has quit [Ping timeout: 260 seconds]
t0xik has joined #ruby
kimoto has quit [Quit: Leaving]
rivalomega has joined #ruby
edwardly has quit [Ping timeout: 276 seconds]
emilford has quit [Ping timeout: 245 seconds]
sanscoeur has joined #ruby
rivalomega has quit [Ping timeout: 260 seconds]
ryzokuken has joined #ruby
harrycs has quit [Quit: Leaving]
edwardly has joined #ruby
edwardly has joined #ruby
edwardly has quit [Changing host]
sumobob has joined #ruby
sumobob has quit [Ping timeout: 245 seconds]
AJA4350 has quit [Remote host closed the connection]
alfiemax has joined #ruby
sumobob has joined #ruby
karapetyan has joined #ruby
xuyuheng has joined #ruby
sumobob has quit [Ping timeout: 260 seconds]
karapetyan has quit [Ping timeout: 260 seconds]
xuyuheng has quit [Quit: Quit: My MacBook Pro has gone to sleep. ZZZzzz?]
cagomez has joined #ruby
houhoulis has joined #ruby
sumobob has joined #ruby
kapil___ has joined #ruby
eb0t_ is now known as def_jam
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
cagomez has quit [Remote host closed the connection]
stairmast0r has quit [Quit: bye]
sumobob has quit [Ping timeout: 245 seconds]
def_jam is now known as eblipo
eblipo is now known as eblip
stairmast0r has joined #ruby
rivalomega has joined #ruby
safetypin has joined #ruby
sysfault has joined #ruby
pilne has quit [Quit: Leaving]
rivalomega has quit [Ping timeout: 252 seconds]
sumobob has joined #ruby
RougeR has quit [Ping timeout: 264 seconds]
alfiemax has quit [Remote host closed the connection]
cadillac_ has quit [Ping timeout: 252 seconds]
alfiemax has joined #ruby
sumobob has quit [Ping timeout: 260 seconds]
cadillac_ has joined #ruby
guacamole has joined #ruby
guacamole has joined #ruby
guacamole has quit [Changing host]
herbmillerjr has joined #ruby
sumobob has joined #ruby
alfiemax has quit [Ping timeout: 248 seconds]
houhoulis has quit [Remote host closed the connection]
houhoulis has joined #ruby
sumobob has quit [Ping timeout: 245 seconds]
amar_ has joined #ruby
safetypin has quit [Quit: ZZZzzz…]
jsrtr has quit [Ping timeout: 260 seconds]
houhoulis has quit [Ping timeout: 252 seconds]
amar_ has quit [Ping timeout: 252 seconds]
sumobob has joined #ruby
jsrtr has joined #ruby
sumobob has quit [Ping timeout: 260 seconds]
ramfjord has joined #ruby
gix- has joined #ruby
gix has quit [Disconnected by services]
ARCADIVS has joined #ruby
ramfjord has quit [Ping timeout: 245 seconds]
thapakazi has joined #ruby
thapakazi_ has joined #ruby
ryzokuken has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ryzokuken has joined #ruby
SuperLag has quit [Quit: reboot]
conr has left #ruby [#ruby]
SuperLag has joined #ruby
white_lilies has quit [Ping timeout: 260 seconds]
anisha has joined #ruby
gnufied has quit [Ping timeout: 260 seconds]
ciscam has quit [Ping timeout: 252 seconds]
ciscam has joined #ruby
white_lilies has joined #ruby
white_lilies has quit [Ping timeout: 260 seconds]
rivalomega has joined #ruby
mtkd has joined #ruby
karapetyan has joined #ruby
karapetyan has quit [Ping timeout: 245 seconds]
duderonomy has quit [Ping timeout: 245 seconds]
ryzokuken has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ryzokuken has joined #ruby
podlech has joined #ruby
ur5us has quit [Remote host closed the connection]
jjunior__ has quit [Quit: Connection closed for inactivity]
podlech has quit [Quit: WeeChat 2.1]
howdoi has joined #ruby
troys has quit [Ping timeout: 245 seconds]
reber has joined #ruby
pabs has quit [Ping timeout: 256 seconds]
pabs has joined #ruby
DoubleMalt has joined #ruby
oleo has quit [Quit: Leaving]
DoubleMalt has quit [Remote host closed the connection]
ta_ has quit [Remote host closed the connection]
ryzokuken is now known as ryzokuken[zzz]
ryzokuken[zzz] is now known as ryzokuken
ryzokuken has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sidx64 has joined #ruby
ogres has quit [Quit: Connection closed for inactivity]
sagax has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
Puffball has quit [Quit: Puffball]
alfiemax has joined #ruby
dionysus69 has joined #ruby
haraoka has joined #ruby
darkhanb has joined #ruby
ryzokuken has joined #ruby
karapetyan has joined #ruby
ramfjord has joined #ruby
ryzokuken has quit [Client Quit]
BTRE has quit [Remote host closed the connection]
sytherax_ has quit [Remote host closed the connection]
sytherax_ has joined #ruby
ramfjord has quit [Ping timeout: 240 seconds]
karapetyan has quit [Ping timeout: 248 seconds]
BTRE has joined #ruby
sytherax_ has quit [Ping timeout: 252 seconds]
conta has joined #ruby
alex`` has joined #ruby
aupadhye has joined #ruby
schleppel has joined #ruby
dviola has quit [Quit: WeeChat 2.1]
apeiros has quit [Remote host closed the connection]
roshanavand has joined #ruby
alfiemax has quit []
sagax has joined #ruby
alfiemax has joined #ruby
ryzokuken has joined #ruby
sauvin has joined #ruby
ryzokuken has quit [Client Quit]
biberu has joined #ruby
jenrzzz has joined #ruby
skryking_ has joined #ruby
dionysus69 has quit [Ping timeout: 245 seconds]
skryking has quit [Ping timeout: 245 seconds]
Azure has quit [Read error: Connection reset by peer]
Azure has joined #ruby
DeepIO has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
mtkd has quit [Ping timeout: 260 seconds]
mtkd has joined #ruby
amar_ has joined #ruby
\void has quit [Quit: So long, and thanks for all the fish.]
amar_ has quit [Ping timeout: 252 seconds]
Guest33581 has quit [Quit: Gateway shutdown]
tvw has joined #ruby
Nussi has quit [Quit: WeeChat 2.1]
sidx64 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sidx64 has joined #ruby
c0ncealed1 has quit [Remote host closed the connection]
c0ncealed1 has joined #ruby
phaul has joined #ruby
alfiemax has quit [Read error: Connection reset by peer]
amar_ has joined #ruby
sidx64 has quit [Client Quit]
alfiemax has joined #ruby
cadillac_ has quit [Read error: Connection reset by peer]
sidx64 has joined #ruby
mikecmpbll has joined #ruby
sidx64 has quit [Client Quit]
cadillac_ has joined #ruby
sidx64 has joined #ruby
dionysus69 has joined #ruby
Mia has quit [Ping timeout: 252 seconds]
Nussi has joined #ruby
DeepIO has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
DeepIO has joined #ruby
DeepIO has quit [Max SendQ exceeded]
paul_ has joined #ruby
sidx64 has quit [Ping timeout: 268 seconds]
suukim has joined #ruby
ta_ has joined #ruby
sidx64 has joined #ruby
conta has quit [Remote host closed the connection]
conta has joined #ruby
clemens3 has joined #ruby
contradictioned has quit [Ping timeout: 260 seconds]
dinfuehr has quit [Ping timeout: 260 seconds]
dinfuehr has joined #ruby
aufi has joined #ruby
amar has joined #ruby
contradictioned has joined #ruby
Mia has joined #ruby
bga57 has quit [Quit: Leaving.]
amar_ has quit [Ping timeout: 252 seconds]
schneider has joined #ruby
bga57 has joined #ruby
alfiemax has quit [Remote host closed the connection]
DeepIO has joined #ruby
claudiuinberlin has joined #ruby
DeepIO has quit [Client Quit]
suukim has quit [Quit: Konversation terminated!]
amar has quit [Remote host closed the connection]
ryzokuken has joined #ruby
amar has joined #ruby
amar has quit [Remote host closed the connection]
amar has joined #ruby
rivalomega has quit [Remote host closed the connection]
Mia has quit [Read error: Connection reset by peer]
arekushi has joined #ruby
fsmauri21 has joined #ruby
ramfjord has joined #ruby
arekushi is now known as Guest33581
marr has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
amar has quit [Remote host closed the connection]
haraoka has quit [Ping timeout: 245 seconds]
ramfjord has quit [Ping timeout: 252 seconds]
alfiemax has joined #ruby
DoubleMalt has joined #ruby
mikecmpb_ has joined #ruby
mlkkk has joined #ruby
Silthias1 has joined #ruby
Burgestrand has joined #ruby
mikecmpbll has quit [Ping timeout: 245 seconds]
Silthias has quit [Ping timeout: 260 seconds]
kapil___ has quit [Quit: Connection closed for inactivity]
samosaphile has joined #ruby
venmx has joined #ruby
DoubleMalt has quit [Quit: Leaving]
ryzokuken is now known as ryzokuken[zzz]
schneider has quit [Ping timeout: 252 seconds]
ur5us has joined #ruby
schneider has joined #ruby
conta1 has joined #ruby
conta has quit [Ping timeout: 248 seconds]
conta1 is now known as conta
amar_ has joined #ruby
amar_ has quit [Remote host closed the connection]
amar_ has joined #ruby
haraoka has joined #ruby
ryzokuken[zzz] is now known as ryzokuken
venmx has quit [Ping timeout: 245 seconds]
conta has quit [Ping timeout: 256 seconds]
guille-moe has joined #ruby
jottr has joined #ruby
karapetyan has joined #ruby
conta has joined #ruby
schneider has quit [Ping timeout: 240 seconds]
mtkd has quit [Ping timeout: 245 seconds]
mtkd has joined #ruby
schneider has joined #ruby
tomeaton17 has joined #ruby
<tomeaton17> I need to install ruby 2.0.0 onto lots of raspberry pi zeros. Is there a way I can do this without having to compile it on every device? takes a long time
jottr has quit [Ping timeout: 245 seconds]
karapetyan has quit [Remote host closed the connection]
Tempesta has quit [Remote host closed the connection]
sidx64 has quit [Quit: Textual IRC Client: www.textualapp.com]
sytherax_ has joined #ruby
venmx has joined #ruby
arquebus has joined #ruby
yohji has joined #ruby
sytherax_ has quit [Ping timeout: 248 seconds]
ryzokuken has quit [Quit: Textual IRC Client: www.textualapp.com]
<clemens3> configure and compile/make on one machine, archive everything, and unzip, and then "make install" on each machine
RyanMcCoskrie has joined #ruby
lxsameer has joined #ruby
<tomeaton17> clemens3: Yeah seems like the way to go. Thanks
<clemens3> welc
arquebus has quit [Quit: Konversation terminated!]
ipe has joined #ruby
beefjoe70 has joined #ruby
amar_ has quit []
amar_ has joined #ruby
karapetyan has joined #ruby
Silthias1 has left #ruby [#ruby]
RyanMcCoskrie has quit [Remote host closed the connection]
plexigras has joined #ruby
<beefjoe70> where can I find a ruby script that captures the stdout ?
amar_ has quit [Ping timeout: 252 seconds]
sytherax_ has joined #ruby
catbusters has joined #ruby
Tempesta has joined #ruby
sytherax_ has quit [Remote host closed the connection]
sytherax_ has joined #ruby
fercell has joined #ruby
rivalomega has joined #ruby
fercell has quit [Client Quit]
ferr_ has joined #ruby
alfiemax has quit [Remote host closed the connection]
NL3limin4t0r has joined #ruby
ferr_ has quit [Client Quit]
alfiemax has joined #ruby
ferr_ has joined #ruby
ferr_ has quit [Client Quit]
ferr_ has joined #ruby
rivalomega has quit [Ping timeout: 240 seconds]
alfiemax has quit [Ping timeout: 245 seconds]
<clemens3> assign a new variable with $stdout, assignt $stdout with StringIO.new
<clemens3> do your thing, later collect the new output with $stdout.string, and reassign the the original state when done
<clemens3> but google might help..
chouhoulis has joined #ruby
haraoka has quit [Ping timeout: 245 seconds]
alfiemax has joined #ruby
mjolnird has quit [Ping timeout: 276 seconds]
venmx has quit [Quit: leaving]
sytherax_ has quit [Remote host closed the connection]
chouhoulis has quit [Ping timeout: 245 seconds]
arne has joined #ruby
<dminuoso> Dont. Monkey patch. Global. Variables.
mjolnird has joined #ruby
<arne> wouldn't it be cool to have a magic variable inside an if true block that has the result of the rexpressio
<dminuoso> No.
ur5us has quit [Remote host closed the connection]
<dminuoso> clemens3: Honestly the second you want this, stop pumping things into stdout.
<dminuoso> You can simply do `yourHandle.puts ...` instead of blindly using Kernel#puts
<arne> dminuoso: why not :(
venmx has joined #ruby
conta has quit [Ping timeout: 245 seconds]
mtkd has quit []
apeiros has joined #ruby
amar_ has joined #ruby
conta has joined #ruby
mtkd has joined #ruby
mikecmpb_ has quit [Quit: inabit. zz.]
mikecmpbll has joined #ruby
contradictioned has quit [Ping timeout: 245 seconds]
contradictioned has joined #ruby
roshanavand has quit [Ping timeout: 245 seconds]
ElFerna has joined #ruby
<clemens3> dminuoso: you anser beefjoe70
amar_ has quit [Remote host closed the connection]
<beefjoe70> well I'm trying to create a script which returns the result of the code to the console
<beefjoe70> so like ruby test.rb 1+1
<beefjoe70> would return 2 to the console
<beefjoe70> `ruby test.rb 1+1`
<beefjoe70> return `2`
<beefjoe70> clemens3
AJA4350 has joined #ruby
ElFerna has quit [Quit: Textual IRC Client: www.textualapp.com]
<clemens3> beefjoe70: ruby -e "put 2 + 2"
<clemens3> puts, damnit:)!
karapetyan has quit [Remote host closed the connection]
<beefjoe70> yea but I wanna have that in a script, so if the given code argument returns an error I'd get that too
roshanavand has joined #ruby
karapetyan has joined #ruby
conta has quit [Remote host closed the connection]
conta has joined #ruby
cschneid has joined #ruby
Mia has quit [Read error: Connection reset by peer]
conta has quit [Client Quit]
conta has joined #ruby
cschneid has quit [Ping timeout: 252 seconds]
sytherax_ has joined #ruby
<clemens3> and the problem is?
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sytherax_ has quit [Ping timeout: 240 seconds]
<beefjoe70> clemens3 this is what I have https://hastebin.com/puzilasida.rb
<beefjoe70> not sure if it's correct, but I'm not even able to pass an argument on the command line :O
contradictioned has quit [Ping timeout: 245 seconds]
Charliebr73 has joined #ruby
contradictioned has joined #ruby
dionysus69 has quit [Quit: dionysus69]
dionysus69 has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
DeepIO has joined #ruby
DeepIO has quit [Max SendQ exceeded]
karapetyan has quit [Remote host closed the connection]
nowhere_man has quit [Ping timeout: 245 seconds]
<paul_> beefjoe70: Maybe the safest way to do what you are trying (so without overriding global variables) would be to create a tmp-file and redirect stdout and stderr to it. Then output that and default stdout and stderr again.
alfiemax_ has joined #ruby
alfiemax has quit [Ping timeout: 252 seconds]
karapetyan has joined #ruby
Mia has joined #ruby
<paul_> So basically craete some tmp-file and use IO#reopen (stderr.reopen(tmpfile); stdout.reopen(tmpfile)) to really capture all of it while not being too intrusive.
<clemens3> beefjoe70: and what's this code example has to do with arguments on the command line..
guille-moe has quit [Quit: guille-moe]
guille-moe has joined #ruby
govg has quit [Quit: leaving]
conta has quit [Ping timeout: 256 seconds]
<clemens3> btw, hastebin doesn't work with a text browser
<beefjoe70> what do you mean
<paul_> beefjoe70: And for the input, lookup the ARGF constant. I think its better suited for your use case than stdin.
<paul_> (it basically acts like a file for the stdin input stream)
<clemens3> beefjoe70: you said you are not even able to pass an argument on the command line, I don't see the relation to your hastbin code example
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<paul_> clemens3 I think thats just what he wants to do with the code once hes got it from the cmd line.
<paul_> with ARGF I think it would just be `Object.instance_eval ARGF.read`
<clemens3> paul_: :)
<beefjoe70> yes exactly paul_
karapetyan has quit [Remote host closed the connection]
karapetyan has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
<paul_> And Im completely wrong about ARGF by the way. It Just replaces file-names in ARGV with their respective contents :/ So I guess STDIN will have to do.
<clemens3> paul_: you meant ARGV..
nowhere_man has joined #ruby
<apeiros> paul_: ARGF is additionally to the files also stdin
<beefjoe70> though I'd rather do it without a tmp file
<beefjoe70> I think eval is good
<beefjoe70> I already wrote the script in another language and it works so I'm trying to convert it
<paul_> As far as I can see ARGF takes ARGV and treats the args as file names. ARGF.read then concatenates all of them. ARGV is just an array of the args (whitespace seperated I think).
<beefjoe70> this works fine with elixir https://pastebin.com/XGqMW4Gj
<ruby[bot]> beefjoe70: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<paul_> so "echo "puts ARGF.read" > argf.rb && ruby argf.rb argf.rb" returns "puts ARGF.read"
Charliebr73 has quit []
<beefjoe70> elixir and ruby seem similar that's why I'm trying to convert the code which works instead of writing from scratch in ruby
dionysus69 has quit [Ping timeout: 256 seconds]
conta has joined #ruby
ur5us has joined #ruby
aufi has quit [Ping timeout: 256 seconds]
dionysus69 has joined #ruby
Cavallari has joined #ruby
ldnunes has joined #ruby
karapetyan has quit [Remote host closed the connection]
nowhere_man has quit [Ping timeout: 245 seconds]
karapetyan has joined #ruby
aufi has joined #ruby
ur5us has quit [Ping timeout: 268 seconds]
TinkerT has quit [Read error: Connection reset by peer]
<beefjoe70> hmm `ruby worker.rb '1+1'` doesn't return anything..
<beefjoe70> using eval()
t0xik has quit [Quit: Connection closed for inactivity]
ciscam has quit [Ping timeout: 245 seconds]
ramfjord has joined #ruby
TinkerT has joined #ruby
ciscam has joined #ruby
catbusters has quit [Quit: Connection closed for inactivity]
alfiemax_ has quit [Remote host closed the connection]
<apeiros> beefjoe70: worker.rb only contains that code?
ramfjord has quit [Ping timeout: 252 seconds]
<beefjoe70> yes
getxsick has joined #ruby
<getxsick> where can i read about behaviour of redifining class in the same file? i notices in pry/irb/ruby that once I redefine class it behaves like inheritance (not overridden methods are available from the old defininion!)
<apeiros> beefjoe70: well, then no wonder. that file only contains a class definition. you never actually invoke Capture.capture.
ryzokuken has joined #ruby
<apeiros> getxsick: redefining a class does not work like inheritance.
<beefjoe70> apeiros then I get `wrong number of arguments (given 0, expected 1) (ArgumentError)`
<apeiros> getxsick: classes and modules in ruby are open. that means you can reopen them. it does not drop or replace the existing definition. you can run additional code in the class body to e.g. add more methods or explicitly remove some or whatever
<apeiros> beefjoe70: and why does that surprise you?
<beefjoe70> because I am passing an rgument
<beefjoe70> argument
<beefjoe70> ruby worker.rb '1+1'
<apeiros> that's not the same
<getxsick> apeiros: yeah, it behaves like that. anyway, so how can i redefine class in Pry? it's pretty common case I believe. i can only restart interpreter?
<beefjoe70> how would I pass it then
<apeiros> Capture.capture is *one method* in your code. ruby will not just send arguments passed to the script to every method you invoke.
<apeiros> ARGV is an array which contains all arguments passed to your script.
<apeiros> getxsick: redefine as in "start over"?
<apeiros> you can't really. you can assign a new class object to the constant. but anything referencing the old class still will.
<apeiros> but most often it's sufficient to just redefine the methods you want
<paul_> getxsick You kann use `remove_const` and then redefine
mtkd has quit []
VladGh has quit [Quit: Lost terminal]
<beefjoe70> `Capture.capture('1+1')` returns the expected result but with an error
<beefjoe70> `undefined local variable or method `result' for Capture:Class (NameError)
<beefjoe70> Did you mean? @result`
<getxsick> paul_: remove_const means i have to call it for each method?
<paul_> No for a class. The class will be gone then ( I guess, never used it myself).
<apeiros> beefjoe70: is there a question in that?
<beefjoe70> no, got it
VladGh has joined #ruby
<beefjoe70> was just sharing what I'm going through
<apeiros> paul_: only the constant is gone. class being an object only will be gone if nothing references it anymore, like I said.
alfiemax has joined #ruby
<getxsick> paul_: no method `remove_const` for a class
<paul_> getxsick Yeah I mistook it for `Module#remove_const`. I thought there was a way to undefine a class though...
<beefjoe70> apeiros doing `Capture.capture(code)` says undefined variable, why's that ?
<apeiros> >> class Foo; end; Object.send(:remove_const, :Foo); Foo # as said, constant *can* be removed
<ruby[bot]> apeiros: # => uninitialized constant Foo (NameError) ...check link for more (https://eval.in/1008132)
<beefjoe70> doing Capture.capture('1+1') works fine though
<apeiros> >> class Foo; end; some_foo_instance = Foo.new; Object.send(:remove_const, :Foo); some_foo_instance.class # however, the *class* is still there, it just can't be accessed through the constant
<ruby[bot]> apeiros: # => Foo (https://eval.in/1008133)
<apeiros> paul_, getxsick: see the above two code examples. I hope those help you to understand how constants & classes are related.
alfiemax has quit [Ping timeout: 248 seconds]
<apeiros> beefjoe70: it usually says undefined variable because you have not defined a variable of that name. I assume it says that about "code"? why do you think that variable should exist there? what should be its value? where did you assign that value to it?
<paul_> apeiros thanks thats a good example :)
alfiemax has joined #ruby
<getxsick> apeiros: thx
<tbuehlmann> apeiros on fire
sytherax_ has joined #ruby
ryzokuken has quit [Read error: Connection reset by peer]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<beefjoe70> I want it to be the argument, as in the code I pass into the class
synthroid has joined #ruby
<beefjoe70> and I have above `def self.capture(code)`
<apeiros> `def self.capture(code)` is for the method side of things, not for the calling side.
<beefjoe70> hmm how do I call the method then ?
<beefjoe70> I can pass arguments to it, it works
<beefjoe70> just not sure how to have that argument as a variable
<apeiros> it means that if you call the method `capture` with an argument, for the piece of code that makes up your method, that argument is assigned to `code`. that is unrelated to code outside the method.
<apeiros> it will work fine with a variable as an argument. but that variable must exist. they don't appear from thin air ;-)
GodFather has joined #ruby
<apeiros> i.e. `code = '1+1'; Capture.capture(code)` will work too.
<beefjoe70> yea, but I want code to be whatever I pass from the console
<beefjoe70> ruby script.rb code
RougeR has joined #ruby
RougeR has joined #ruby
RougeR has quit [Changing host]
<apeiros> yes. and ARGV contains those values.
duderonomy has joined #ruby
conta has quit [Ping timeout: 264 seconds]
conta has joined #ruby
karapetyan has quit [Remote host closed the connection]
karapetyan has joined #ruby
<beefjoe70> weird, I keep getting `["worker.rb:9:in `eval'", "worker.rb:9:in `capture'", "worker.rb:22:in `<main>'"]`
<beefjoe70> doesn't matter what's the argument
<beefjoe70> I have code = argv
alfiemax has quit [Remote host closed the connection]
<apeiros> ok, please be precise. ARGV != argv.
<apeiros> note that ARGV is an array, it's not a string
<apeiros> each element in the array is one argument
<beefjoe70> oh I see
<beefjoe70> now I used ARGV[0]
<beefjoe70> works
<beefjoe70> thanks :D
<apeiros> you're welcome
sphenxes has joined #ruby
<apeiros> beefjoe70: note: you should always reassign $stderr in your code. otherwise you'll miss it if the code emits something on stderr.
<apeiros> and plain puts will write to stdout anyway, not to stderr. so it's pointless in the rescue.
sytherax_ has quit [Remote host closed the connection]
<beefjoe70> $stdout, $stderr = STDOUT, STDERR ?
<beefjoe70> to reassign
<apeiros> no, that part is fine. I mean before you run the code.
alfiemax has joined #ruby
alfiemax has quit [Read error: Connection reset by peer]
alfiemax has joined #ruby
<beefjoe70> But the way I have it, it should write correctly to stderr and stdout correct ?
<beefjoe70> I mean I get the correct output on the console, but need to capture the result accordingly as well
alfiemax_ has joined #ruby
<apeiros> define "correctly". as said, the part in the rescue now is pointless. and you'll miss it if the passed script emits something on $stderr.
<beefjoe70> gonna use the captured result with node
<beefjoe70> well when I do ruby script.rb "1+"
<beefjoe70> it returns an error
conta1 has joined #ruby
darix has quit [Quit: may the packets be with you...]
<apeiros> take a close look on where it returns that error.
<beefjoe70> ["worker.rb:9:in `eval'", "worker.rb:9:in `capture'", "worker.rb:22:in `<main>'"]
<beefjoe70> yea true
sytherax_ has joined #ruby
conta has quit [Ping timeout: 245 seconds]
conta1 is now known as conta
<beefjoe70> this isn't what I want
<apeiros> not what I meant
<apeiros> the backtrace itself is fine
<apeiros> though of course you can remove the running env from it. but that's not what I mean.
<apeiros> 14:27 apeiros: and plain puts will write to stdout anyway, not to stderr. so it's pointless in the rescue.
alfiemax has quit [Ping timeout: 252 seconds]
<beefjoe70> hmm but I need to know when there's an error and write it to stderr
<beefjoe70> I don't want it all in stdout
<apeiros> "and write it to stderr" - but you do not write it to stderr.
<apeiros> currently you write it to stdout
<beefjoe70> yea I got that, thanks for letting me know
<beefjoe70> how can I write to stderr ?
<apeiros> $stderr.puts
<beefjoe70> shouldn't I also do $stdout.puts to write to out ?
karapetyan has quit [Remote host closed the connection]
guille-moe has quit [Quit: guille-moe]
<apeiros> you can, but you don't have to
guille-moe has joined #ruby
<apeiros> plain `puts` is Kernel#puts, which is $stdout.puts
<beefjoe70> interesting
<beefjoe70> Looks good now
<beefjoe70> works good, with errors as well
<apeiros> and now try `ruby worker.rb '$stderr.puts "I go missing!"'`
<beefjoe70> `I go missing!`
<beefjoe70> lovely
<apeiros> o0
<apeiros> but not in your return value…
<beefjoe70> why
<beefjoe70> I get I go missing!
<apeiros> on your screen, yes
shinnya has joined #ruby
<apeiros> huh, I see, your code has changed…
<beefjoe70> now doing ruby -e puts $stderr returns nothing
<apeiros> what happened to the `OpenStruct.new result: result, stdout: stdout.string, stderr: stderr.string` thing?
<beefjoe70> removed it
karapetyan has joined #ruby
<apeiros> so capture does not really have a return value. not sure how you want to use this thing then.
<beefjoe70> because it produced an error
<beefjoe70> undefined method `string' for nil:NilClass (NoMethodError)
darix has joined #ruby
getxsick has quit [Read error: Connection reset by peer]
jrafanie has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
<apeiros> beefjoe70: I'll ask as before - is there a question in that? :)
<beefjoe70> Why does it produce that error ?
<beefjoe70> btw doing ruby -e puts $stdout also returns nothing
<apeiros> what did you consider as likely reasons?
<beefjoe70> I'm not capturing the result
<beefjoe70> only printing it on the consol
mtkd has joined #ruby
<apeiros> (I might be replying slowly, working on the side…)
<beefjoe70> tyt
<apeiros> we'll look at your `ruby -e` later.
<apeiros> what do you understand about the error text "undefined method `string' for nil:NilClass (NoMethodError)"?
<apeiros> what does it tell you
ramfjord has joined #ruby
<beefjoe70> the string method isn't defined
<beefjoe70> I used it from this one here http://alphahydrae.com/2013/09/capturing-output-in-pure-ruby/
<beefjoe70> which explains how to capture stdout and stderr
<apeiros> ok. and on which objects do you try to call `.string`?
<apeiros> or maybe first: which line is the one that causes the problem?
<beefjoe70> 21
<beefjoe70> so I guess both times on stdout and stderr
<beefjoe70> btw this is the code I'm working on https://hastebin.com/zoyukopaza.rb
<apeiros> ok. so either stdout.string, or stderr.string fail with that error.
sytherax_ has quit [Remote host closed the connection]
<beefjoe70> hmm so I need to call each one in it's own code block ?
<apeiros> the "nil:NilClass" part gives you info about the object you try to call `.string` on. it means you call it on nil (which is an instance of NilClass)
contradictioned has quit [Ping timeout: 245 seconds]
<apeiros> no. you have to figure out which of the two is failing.
<apeiros> from which you can then draw further conclusions.
ramfjord has quit [Ping timeout: 252 seconds]
<beefjoe70> it's this stderr: stderr.string
<apeiros> and hopefully ultimately fix your bug.
<apeiros> ok. so the error tells you that stderr is nil, an instance of NilClass. what did you expect it to be?
<beefjoe70> the value of the error, if there's one
<beefjoe70> fixed it
<apeiros> ok, let me ask differently. the object assigned to stderr, of which class should it be an instance?
<beefjoe70> well at least no error now
<beefjoe70> not sure if it works properly
<apeiros> yeah, that's not a fix.
<apeiros> that's a "I stopped the pipe from leaking by closing the valve" :-p
<beefjoe70> lol
<apeiros> I try to get you to learn to understand your errors and follow them back to their origin, and then actually fix it.
<beefjoe70> yea I appreciate it
contradictioned has joined #ruby
<beefjoe70> no idea how to proceed
<apeiros> proceed with my question :)
<apeiros> > ok, let me ask differently. the object assigned to stderr, of which class should it be an instance?
sytherax_ has joined #ruby
ogres has joined #ruby
<beefjoe70> Capture ?
<beefjoe70> my class
<apeiros> o0
<apeiros> ok, in which line do you for the first time assign something to `stderr`?
<beefjoe70> stderr = StringIO.new
<beefjoe70> after the rescue
paul_ has quit [Ping timeout: 252 seconds]
<apeiros> and after that line you expect `stderr.class` to be Capture?
<beefjoe70> oh right right
<beefjoe70> it's gotta be of the stringio class
<apeiros> ok. but in the line which raises, it is NilClass
<apeiros> so why is it nil, while expect it to be a StringIO instance? got an idea?
<beefjoe70> no clue
<apeiros> is the line `stderr = StringIO.new` always executed?
<apeiros> I mean, if you call Capture.capture
<beefjoe70> no not necessarily
<beefjoe70> if there's no error, then no
<apeiros> ok. so if there's no error, what value will `stderr` have?
<beefjoe70> the error message ?
<apeiros> what error message? there is no error…
<beefjoe70> oh no error
<beefjoe70> then nil
<apeiros> ok. so when there's no error, stderr will be nil, which in turn causes an exception because there's no nil.string. so that's your issue.
<apeiros> got an idea on how to solve that?
<beefjoe70> so what's wrong with the way I did it afterwards ? to only call .string when there's an error
<apeiros> the only "afterwards" I've seen was when you just commented out the entire OpenStruct line.
<beefjoe70> look line 19
<beefjoe70> and 13
<apeiros> oh. worse even. you create an object which you throw away :D
<beefjoe70> lol
<apeiros> but yes, the stderr/stdout part would work.
<beefjoe70> the problem is that I'm not catching it, correct ?
<beefjoe70> because doing ruby -e doesn't return the stdout for example
<apeiros> you have to start distinguishing between "return" and "print"
<apeiros> those two are not the same and not interchangeable.
<apeiros> shell scripts don't return. they print stuff. usually on stdout/stderr.
<beefjoe70> so how do I return to stdout and stderr
<beefjoe70> not just print
<apeiros> in ruby, the last value of a method is returned. you can also explicitly use the return statement.
howdoi has quit [Quit: Connection closed for inactivity]
<apeiros> >> def foo; "hello"; "world"; end; foo
<ruby[bot]> apeiros: # => "world" (https://eval.in/1008187)
<apeiros> >> def foo; return "hello"; "world"; end; foo
<ruby[bot]> apeiros: # => "hello" (https://eval.in/1008188)
tvw has quit []
ByronJohnson has quit [Ping timeout: 256 seconds]
aufi has quit [Remote host closed the connection]
bmurt has joined #ruby
samort7 has joined #ruby
ByronJohnson has joined #ruby
<sysfault> shell scripts return values which are stored in $?
thapakazi_ has quit [Ping timeout: 252 seconds]
thapakazi has quit [Ping timeout: 252 seconds]
<beefjoe70> now stderr returns nothing lol
<beefjoe70> require 'stringio'
<beefjoe70> require 'ostruct'
<beefjoe70> class Capture
<beefjoe70> def self.capture(code)
<beefjoe70> begin
<beefjoe70> stdout = StringIO.new
<beefjoe70> $stdout = stdout
<beefjoe70> puts eval(code)
<beefjoe70> OpenStruct.new stdout: stdout.string
<beefjoe70> STDOUT.puts $stdout.string
<beefjoe70> rescue Exception => e
<beefjoe70> stderr = StringIO.new
<beefjoe70> $stderr = stderr
<beefjoe70> $stderr.puts
<beefjoe70> puts e.message
<beefjoe70> OpenStruct.new stderr: stderr.string
<beefjoe70> STDERR.puts $stderr.string
<beefjoe70> end
<beefjoe70> I get the correct stdout result printed, but not stderr when there's an error
<beefjoe70> even though I have puts e.message
KeyJoo has joined #ruby
KeyJoo has quit [Max SendQ exceeded]
KeyJoo has joined #ruby
marr has quit [Ping timeout: 245 seconds]
sytherax_ has quit [Remote host closed the connection]
apparition has joined #ruby
brendan- has joined #ruby
Asher has quit [Ping timeout: 260 seconds]
sytherax_ has joined #ruby
ta_ has quit [Remote host closed the connection]
<apeiros> beefjoe70: please paste >3 lines on gist (or another paste service)
ohcibi has quit [Remote host closed the connection]
<apeiros> $stderr.puts is just the method. you have to actually print something.
<apeiros> foo.bar(baz) # <-- call the method "bar" on the object referenced by "foo" and pass it one argument "baz"
<apeiros> that's 101 though and it might be a good idea you start reading a book to get those 101
kapil___ has joined #ruby
nowhere_man has joined #ruby
karapetyan has quit [Remote host closed the connection]
karapetyan has joined #ruby
ohcibi has joined #ruby
schneider has quit [Quit: WeeChat 2.0.1]
phaul has quit [Ping timeout: 240 seconds]
quobo has joined #ruby
<beefjoe70> but I have puts e.message
<beefjoe70> which should print the error ?
<apeiros> to stdout, yes. and where does stdout go?
<apeiros> eh, since you named your lvar "stdout" let me be more precise:
<apeiros> to $stdout, yes. and where does stdout go?
<apeiros> whoops, premature enter :D
<apeiros> to $stdout, yes. and where does $stdout go? # final
rivalomega has joined #ruby
beefjoe70 has quit [Remote host closed the connection]
karapetyan has quit [Remote host closed the connection]
aupadhye has quit [Ping timeout: 240 seconds]
apeiros has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
pastorinni has joined #ruby
catbusters has joined #ruby
aufi has joined #ruby
conta2 has joined #ruby
Rapture has joined #ruby
conta has quit [Ping timeout: 264 seconds]
conta2 is now known as conta
amelliaa has joined #ruby
rivalomega has quit [Remote host closed the connection]
Asher has joined #ruby
Asher is now known as Guest54899
gnufied has joined #ruby
dionysus69 has quit [Ping timeout: 252 seconds]
safetypin has joined #ruby
<fsmauri21> Ok so in one of the exercises it has puts "Roosters #{100 - 25 * 3 % 4}"
pastorinni has quit [Remote host closed the connection]
<fsmauri21> After I ran the file, it gave me Roosters 97
<fsmauri21> My question is how is % used in that context?
<fsmauri21> I looked it up and got so many other answers..
<fsmauri21> Is it a remainder? Or does it work like an array?
Guest54899 has quit [Ping timeout: 245 seconds]
ohcibi has quit [Remote host closed the connection]
ohcibi has joined #ruby
pastorinni has joined #ruby
pastorinni has quit [Read error: Connection reset by peer]
pastorinni has joined #ruby
banisterfiend has joined #ruby
<canton7> it's remainder.
<canton7> 75 % 4 = 3, because 4 * 18 = 72, and 75 - 72 = 3
karapetyan has joined #ruby
<fsmauri21> Ok thanks.
<havenwood> FsMauri21: You can alternatively use the Integer#modulo method for the same effect.
<havenwood> >> 75.modulo(4) == 75 % 4
<ruby[bot]> havenwood: # => true (https://eval.in/1008230)
banisterfiend has quit [Client Quit]
sytherax_ has quit [Remote host closed the connection]
<havenwood> >> 75.divmod(4) == [75 / 4, 75 % 4]
<ruby[bot]> havenwood: # => true (https://eval.in/1008232)
<fsmauri21> Thats a neat bot.
* havenwood bows
sytherax_ has joined #ruby
face has joined #ruby
* havenwood realizes he's not the bot.
karapetyan has quit [Ping timeout: 245 seconds]
<fsmauri21> Ah man, would have been a nice AI bot..
Torstein has joined #ruby
faces has quit [Ping timeout: 260 seconds]
<apeiros> FsMauri21: and how to look it up: figure out on what value it is invoked on (in this case on 25*3 == 75), figure out the class of that (75.class => Integer) and then use ri in your console: `ri Integer#%`
<apeiros> alternatively to ri, you can also use ruby-doc.org or another API doc website. just don't use google. that's a rather bad way to access api docs :)
<fsmauri21> I knew the math it was doing, but I wanted to be able to understand it in words.
<fsmauri21> Reading up on it, it has other uses and that was slightly confusing.
<Torstein> I've got a bsearch question; is it possible to find the highest value less than x?
<havenwood> >> 75.method(:%).owner
<ruby[bot]> havenwood: # => Fixnum (https://eval.in/1008239)
<Torstein> lowest value is trivial: Array.new(20) { rand 1000 }.sort.bsearch { |n| n > 250 }
faces has joined #ruby
<Torstein> but how to find the highest value below 750?
<havenwood> Torstein: That'll often be a different value, not the lowest.
<fsmauri21> Thanks for the page link Apeiros.
<Torstein> really?
<havenwood> Torstein: Try it a few times in irb or pry.
<havenwood> Torstein: Note the value changes.
alfiemax_ has quit [Remote host closed the connection]
chouhoulis has joined #ruby
face has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
<Torstein> yes, that is what I want. the lowest value above 250, naturally it will change with the random values.
<Torstein> Array.new(20) { rand 1000 }.sort.tap { |a| puts a }.bsearch { |n| n > 250 } <--- you expect this not to return the lowest value above 250?
<Torstein> tried it a few times in irb, looks to be working the way I expect
Cavallari has quit [Quit: Cavallari]
<havenwood> Torstein: Ah, I misunderstood what you were asking. Nvm!
<Torstein> yeah, so I want to go from the other side, and find the _highest_ value _below_ 750
<havenwood> Torstein: You could reverse the sort.
<Torstein> (without using reverse)
<Torstein> oh :P
dviola has joined #ruby
<havenwood> Torstein: sort_by { |n| -n }.bsearch { |n| n < 250 }
<Torstein> reverse is O(n)?
<havenwood> But yeah, reversing. ;-P
<havenwood> Torstein: You can do it when you sort, so you don't have to sort then reverse.
conta has quit [Ping timeout: 268 seconds]
jamiejackson has joined #ruby
<Torstein> how do you mean?
alfiemax has quit [Ping timeout: 252 seconds]
<havenwood> Torstein: You're sorting by n, but you can just sort by -n.
<havenwood> It'll end up in the reverse order.
conta has joined #ruby
<Torstein> hmm
<Torstein> ok, let me backtrack
<Torstein> I got a SortedSet
<Torstein> and I want to get the elements in the range from X to Y
sytherax_ has quit [Remote host closed the connection]
<Torstein> Array.new(20) { rand 1000 }.to_set.get_range(250, 750) # Imagine we required 'set' and inherited from it so that we can implement get_range(min, max)
karapetyan has joined #ruby
<Torstein> there has to be a way to get the highest value of the set below 750 in O(lg n), right?
jamiejackson has quit [Remote host closed the connection]
justizin has joined #ruby
conta has quit [Ping timeout: 245 seconds]
Cavallari has joined #ruby
<havenwood> f
apparition has quit [Quit: Bye]
<havenwood> Torstein: Do you want the range or the min and max value?
<havenwood> I guess you were only getting min and max to get at the range?
<Torstein> yeah, I want the indexes of the min and max values within the range, so that I can do some_sorted_set.to_a.values_at(min..max)
<Torstein> (min_index..max_index) would be better var names
<Torstein> and the goal is to find both min_index and max_index in O(lg n)
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 256 seconds]
AJA4351 is now known as AJA4350
<havenwood> Torstein: bsearch is indeed fast
<havenwood> it's the most contorted code, by far
mtkd has quit [Ping timeout: 260 seconds]
grilix has joined #ruby
mtkd has joined #ruby
sytherax_ has joined #ruby
<havenwood> The difference gets bigger as the SortedSet grows.
Burgestrand has quit [Quit: Closing time!]
demio has joined #ruby
<Torstein> nice :)
orbyt_ has joined #ruby
<arne> when i do eval "w = 3"
<Torstein> hmm.. I suppose reversing will have to do for now
<arne> why don't i have eval inside the currenct scope?
rivalomega has joined #ruby
<havenwood> >> binding == binding
<ruby[bot]> havenwood: # => false (https://eval.in/1008268)
<Torstein> try Kernel.eval "w = 3"
shinnya has quit [Ping timeout: 252 seconds]
<arne> does binding always return a new binding?
demio has left #ruby [#ruby]
<havenwood> >> this_binding = binding; this_binding.eval 'w = 3'; this_binding.eval 'w'
<ruby[bot]> havenwood: # => 3 (https://eval.in/1008270)
<arne> i see, thanks
<arne> i guess it does, except for <cases>
<Torstein> huh
<arne> like being inside a proc or something?
oleo has joined #ruby
Asher has joined #ruby
AJA4351 has joined #ruby
<havenwood> arne: eval takes a binding as a second arg
rivalomega has quit [Remote host closed the connection]
<havenwood> bbtw
rivalomega has joined #ruby
AJA4350 has quit [Ping timeout: 252 seconds]
AJA4351 is now known as AJA4350
<havenwood> >> this_binding = binding; eval 'w = 3', this_binding; this_binding.eval 'w'
<ruby[bot]> havenwood: # => 3 (https://eval.in/1008273)
<arne> ah, i even used this once
<arne> thanks alot
<havenwood> err, I mean:
<havenwood> >> this_binding = binding; eval 'w = 3', this_binding; eval 'w', this_binding
<arne> binding still confusing imho
<ruby[bot]> havenwood: # => 3 (https://eval.in/1008275)
<havenwood> arne: yeah
<arne> is it Kernel#binding?
<arne> where can i read about it
biberu has quit []
<arne> so binding returns a copy of the current scope?
<arne> not the scope itself?
<arne> or rather a "child" of the scope?
cschneid has joined #ruby
Torstein has quit [Ping timeout: 260 seconds]
Asher has quit [Ping timeout: 240 seconds]
phaul has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4350 has joined #ruby
coderphive has joined #ruby
marr has joined #ruby
cyberg has joined #ruby
sumobob has joined #ruby
<arne> man i love ruby c code
<arne> not
sanscoeur has quit [Remote host closed the connection]
rivalomega has quit [Remote host closed the connection]
<RougeR> does this look right?
<RougeR> @gyms = Gym.where({created_at: (Time.now - 48.hours)..Time.now, active: false)}
<RougeR> syntax error, unexpected ')', expecting '}'
<havenwood> RougeR: Nope!
<havenwood> RougeR: There are a couple issues.
<havenwood> RougeR: The most immediate is that the ) and } at the end are in the wrong order.
<arne> havenwood: but as far as i understand it creates a new binding and writes stuff to it, so it would be some sort of a copy?
<RougeR> havenwood: really?
<RougeR> its obvious not right i agree
<RougeR> i was following this
<RougeR> User.where({ name: "Joe", email: "joe@example.com" })
<havenwood> arne: I mean it's a new Binding object, so it's a thing in itself. It has references to the point of call from the scope where it was made.
<RougeR> havenwood: ah shit
<RougeR> i see it
<RougeR> at the end brackets
<RougeR> working now
<arne> havenwood: so a copy :D at that time
<havenwood> arne: Nothing is copied though, just a binding.
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> arne: Yeah, I see what you're saying.
<fsmauri21> Thanks again Havenwood. Adios.
<havenwood> Maybe copy isn't the best word. But yes.
fsmauri21 has left #ruby ["Leaving"]
<havenwood> arne: I don't understand it well enough to explain it. ;-)
ldnunes has quit [Ping timeout: 260 seconds]
<arne> havenwood: okay, thanks alot
yohji has quit [Remote host closed the connection]
clemens3 has quit [Ping timeout: 256 seconds]
pastorin_ has joined #ruby
pastorinni has quit [Read error: Connection reset by peer]
sytherax_ has quit [Remote host closed the connection]
apeiros has quit [Read error: Connection reset by peer]
aufi has quit [Quit: Leaving]
sytherax_ has joined #ruby
ldnunes has joined #ruby
banisterfiend has joined #ruby
sytherax_ has quit [Ping timeout: 260 seconds]
Zaab1t has joined #ruby
rivalomega has joined #ruby
nielsk has quit [Ping timeout: 276 seconds]
pastorin_ has quit [Read error: Connection reset by peer]
pastorinni has joined #ruby
cagomez has joined #ruby
kmurphy4 has joined #ruby
nielsk has joined #ruby
cagomez has quit []
cagomez has joined #ruby
dionysus69 has joined #ruby
alex`` has quit [Quit: WeeChat 2.1]
apeiros has joined #ruby
jcarl43 has joined #ruby
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pastorinni has quit [Read error: No route to host]
pastorinni has joined #ruby
apeiros has quit [Ping timeout: 245 seconds]
guille-moe has quit [Ping timeout: 260 seconds]
npgm has joined #ruby
conta has joined #ruby
karapetyan has quit [Remote host closed the connection]
KeyJoo has quit [Ping timeout: 256 seconds]
karapetyan has joined #ruby
GodFather has quit [Ping timeout: 240 seconds]
Xeago has quit [Quit: ZNC 1.7.0 - https://znc.in]
Xeago has joined #ruby
DTZUZU has quit [Quit: WeeChat 1.9]
amar_ has joined #ruby
thapakazi has joined #ruby
thapakazi_ has joined #ruby
orbyt_ has joined #ruby
orbyt_ has quit [Client Quit]
KeyJoo has joined #ruby
[Butch] has joined #ruby
apeiros has joined #ruby
bmurt has joined #ruby
amar_ has quit [Ping timeout: 252 seconds]
AJA4350 has quit [Ping timeout: 240 seconds]
shinnya has joined #ruby
[Butch] has quit [Client Quit]
apeiros has quit [Ping timeout: 245 seconds]
cthulchu has joined #ruby
darkhanb has joined #ruby
[Butch] has joined #ruby
apeiros has joined #ruby
guille-moe has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
nowhere_man has quit [Ping timeout: 256 seconds]
coderphive has quit [Quit: coderphive]
grilix has quit [Read error: Connection reset by peer]
sumobob has quit [Ping timeout: 245 seconds]
ta_ has joined #ruby
grilix has joined #ruby
\void has joined #ruby
Mike11 has joined #ruby
clemens3 has joined #ruby
suukim has joined #ruby
sumobob has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
guacamole has joined #ruby
guacamole has joined #ruby
guacamole has quit [Changing host]
ta_ has quit [Ping timeout: 245 seconds]
brendan- has quit [Ping timeout: 245 seconds]
shinnya has quit [Ping timeout: 248 seconds]
guacamole has quit [Client Quit]
sumobob has quit [Ping timeout: 245 seconds]
guacamole has joined #ruby
guacamole has joined #ruby
guacamole has quit [Changing host]
guacamole has quit [Client Quit]
Cavallari has quit [Quit: Cavallari]
NL3limin4t0r has quit [Quit: WeeChat 1.9.1]
nowhere_man has joined #ruby
sanscoeur has joined #ruby
<cagomez> is it possible to splat a hash without passing it as a param? ie just `*hash.values` returned from a method
sanscoeur has quit [Remote host closed the connection]
<dminuoso> cagomez: what does "splat a hash" mean for you
sumobob has joined #ruby
nitric has joined #ruby
sanscoeur has joined #ruby
safetypin has quit [Ping timeout: 264 seconds]
<dminuoso> cagomez: hash.values returns an array.
amar_ has joined #ruby
<cagomez> ah ok, got it
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mtkd has quit [Ping timeout: 245 seconds]
Silox| has joined #ruby
pilne has joined #ruby
mtkd has joined #ruby
kmurphy4 has quit [Quit: Leaving]
guille-moe has quit [Ping timeout: 240 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4350 has joined #ruby
DTZUZU has joined #ruby
guacamole has joined #ruby
mlkkk has quit [Remote host closed the connection]
mlkkk has joined #ruby
AgentVenom has joined #ruby
Puffball has joined #ruby
ogres has quit [Quit: Connection closed for inactivity]
pastorinni has quit [Read error: No route to host]
nowhere_man has quit [Remote host closed the connection]
pastorinni has joined #ruby
nowhere_man has joined #ruby
mlkkk has quit [Ping timeout: 245 seconds]
guacamole has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
armyriad has quit [Quit: Leaving]
venmx has quit [Ping timeout: 252 seconds]
iceden has quit [Remote host closed the connection]
synthroid has quit [Remote host closed the connection]
ogres has joined #ruby
sudorobo has quit [Quit: ¯\_(ツ)_/¯]
sudorobo has joined #ruby
sudorobo has joined #ruby
SirFunk has quit [Quit: ZNC - http://znc.in]
conta has quit [Read error: Connection reset by peer]
conta has joined #ruby
SirFunk has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
guacamole has joined #ruby
guacamole has joined #ruby
guacamole has quit [Changing host]
conta has quit [Ping timeout: 240 seconds]
SirFunk has quit [Client Quit]
brendan- has joined #ruby
chouhoul_ has joined #ruby
guacamole has quit [Ping timeout: 264 seconds]
justizin has quit [Quit: Connection closed for inactivity]
jenrzzz has joined #ruby
synthroid has joined #ruby
chouhoul_ has quit [Remote host closed the connection]
chouhoul_ has joined #ruby
chouhoulis has quit [Ping timeout: 245 seconds]
SirFunk has joined #ruby
dviola has quit [Quit: WeeChat 2.1]
mjolnird has quit [Ping timeout: 260 seconds]
hahuang65 has quit [Quit: ZNC 1.6.6 - http://znc.in]
thapakazi_ has quit [Quit: thapakazi_]
thapakazi has quit [Quit: thapakazi]
conta has joined #ruby
mtkd has quit []
mtkd has joined #ruby
GodFather has joined #ruby
conta has quit [Ping timeout: 256 seconds]
jrafanie has joined #ruby
<RougeR> heya, i need some help with my join table
<RougeR> ive not really used one before. im pretty sure the relations are correct
<RougeR> but im confused on how to start saving relations
<RougeR> records*
catbusters has quit [Quit: Connection closed for inactivity]
paul_ has joined #ruby
<RougeR> x-posting to #RoR
banisterfiend has joined #ruby
Axy has joined #ruby
Axy has joined #ruby
Axy has quit [Changing host]
Asher has joined #ruby
matled- has joined #ruby
sumobob has quit [Quit: WeeChat 1.7]
Mia has quit [Ping timeout: 252 seconds]
dviola has joined #ruby
nitric_ has joined #ruby
jrich523 has joined #ruby
nayena has joined #ruby
matled has quit [Remote host closed the connection]
matled- is now known as matled
amar has joined #ruby
nitric has quit [Ping timeout: 260 seconds]
Asher has quit [Ping timeout: 240 seconds]
Mia has joined #ruby
amar_ has quit [Ping timeout: 252 seconds]
nayena has quit [Ping timeout: 245 seconds]
tacoboy has quit [Read error: Connection reset by peer]
Axy has quit [Ping timeout: 252 seconds]
mtkd has quit []
Axy has joined #ruby
Axy has joined #ruby
Axy has quit [Changing host]
quobo has quit [Quit: Connection closed for inactivity]
darkhanb has quit [Ping timeout: 260 seconds]
Axy has quit [Read error: Connection reset by peer]
Mia has quit [Ping timeout: 252 seconds]
Mia has joined #ruby
ramfjord has joined #ruby
suukim has quit [Quit: Konversation terminated!]
sphenxes has quit [Quit: Leaving]
phaul has quit [Ping timeout: 248 seconds]
sauvin has quit [Remote host closed the connection]
conta has joined #ruby
phaul has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<cagomez> why can't I call `current_time_from_proper_timezone` on a ActiveRecord class? https://github.com/rails/rails/blob/master/activerecord/lib/active_record/timestamp.rb#L60
<cagomez> but if I initialize a model, I can do `model.send(:current_time_from_proper_timezone)`
bmurt has joined #ruby
Asher has joined #ruby
guille-moe has joined #ruby
Cavallari has joined #ruby
mtkd has joined #ruby
Cavallari has quit [Client Quit]
ARCADIVS has quit [Quit: WeeChat 2.0.1]
t0xik has joined #ruby
guille-moe has quit [Ping timeout: 245 seconds]
pastorinni has quit [Ping timeout: 248 seconds]
Axy has joined #ruby
coderphive has joined #ruby
Mia has quit [Ping timeout: 252 seconds]
phaul has quit [Ping timeout: 252 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chouhoulis has joined #ruby
Axy has quit [Read error: Connection reset by peer]
paul_ has quit [Ping timeout: 260 seconds]
chouhoul_ has quit [Ping timeout: 260 seconds]
alfiemax has joined #ruby
cadillac_ has quit [Ping timeout: 252 seconds]
rivalomega has quit [Remote host closed the connection]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rivalomega has joined #ruby
rivalomega has quit [Remote host closed the connection]
jarnalyrkar has joined #ruby
cadillac_ has joined #ruby
rivalomega has joined #ruby
rivalomega has quit [Read error: Connection reset by peer]
rivalomega has joined #ruby
mjolnird has joined #ruby
SuperL4g has joined #ruby
karapetyan has quit [Remote host closed the connection]
anisha has quit [Quit: This computer has gone to sleep]
bmurt has joined #ruby
ogres has quit [Quit: Connection closed for inactivity]
karapetyan has joined #ruby
SuperLag has quit [Ping timeout: 245 seconds]
quobo has joined #ruby
mikecmpbll has joined #ruby
_aeris_ has quit [Remote host closed the connection]
jmaister has joined #ruby
Silox| has quit [Quit: Connection closed for inactivity]
<jmaister> Hi! I'm trying to get r18n to work, but have little success. I have this very simple program https://pastebin.com/iSLrv8nf and a translation file https://pastebin.com/eRuxU8Vn in the correct place, but it doesn't seem to find my translation
<ruby[bot]> jmaister: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<jmaister> ok
alfiemax has quit [Remote host closed the connection]
<jmaister> I tried in irb, and it gives me this https://gist.github.com/jurgemaister/977832fbe6565671c735773b39dfc130 @untranslated_path="file.add"
_aeris_ has joined #ruby
GodFather has quit [Read error: No route to host]
sudorobo has quit [Quit: ¯\_(ツ)_/¯]
sudorobo has joined #ruby
sudorobo has joined #ruby
alfiemax has joined #ruby
BH23 has joined #ruby
cagomez has quit [Remote host closed the connection]
cagomez has joined #ruby
rivalomega has quit [Remote host closed the connection]
alfiemax has quit [Ping timeout: 252 seconds]
<jmaister> never mind, I called my yaml file .yaml and not .yml. I'm stupid
cagomez has quit [Ping timeout: 252 seconds]
banisterfiend has joined #ruby
GodFather has joined #ruby
rivalomega has joined #ruby
rivalomega has quit [Remote host closed the connection]
rivalomega has joined #ruby
Zaab1t has quit [Quit: Zaab1t]
herbmillerjr has joined #ruby
alfiemax has joined #ruby
darkhanb has joined #ruby
eckhardt has joined #ruby
alfiemax has quit [Ping timeout: 245 seconds]
apeiros has quit [Ping timeout: 248 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz_ has joined #ruby
banisterfiend has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
cagomez has joined #ruby
Torstein has joined #ruby
joro_ has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cagomez has quit [Ping timeout: 256 seconds]
jmaister has left #ruby [#ruby]
bmurt has joined #ruby
brendan- has quit [Ping timeout: 252 seconds]
bmurt has quit [Ping timeout: 245 seconds]
bmurt has joined #ruby
KeyJoo has quit [Remote host closed the connection]
sinduck has joined #ruby
alfiemax has joined #ruby
mikecmpbll has quit [Quit: inabit.]
nayena has joined #ruby
mikecmpbll has joined #ruby
conta has quit [Ping timeout: 260 seconds]
alfiemax has quit [Ping timeout: 260 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nayena has quit [Ping timeout: 245 seconds]
amelliaa has quit [Ping timeout: 264 seconds]
schleppel has quit [Read error: Connection reset by peer]
Dbugger has joined #ruby
synthroid has quit []
nkh^ has joined #ruby
duderonomy has quit [Ping timeout: 260 seconds]
cagomez has joined #ruby
duderonomy has joined #ruby
cagomez has quit [Ping timeout: 248 seconds]
rivalomega has quit [Remote host closed the connection]
Torstein has quit [Quit: Page closed]
rivalomega has joined #ruby
vulgrin has joined #ruby
rivalomega has quit [Remote host closed the connection]
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
vulgrin has quit [Client Quit]
vulgrin has joined #ruby
GodFather has quit [Read error: No route to host]
reber has quit [Remote host closed the connection]
havenwood has quit [Quit: ZNC 1.6.6 - http://znc.in]
jarnalyrkar has quit [Quit: Leaving]
nkh^ has quit [Ping timeout: 245 seconds]
havenwood has joined #ruby
havenwood has joined #ruby
rivalomega has joined #ruby
rivalomega has quit [Read error: Connection reset by peer]
rivalome_ has joined #ruby
rivalome_ has quit [Remote host closed the connection]
rivalomega has joined #ruby
tdy has quit [Read error: Connection reset by peer]
grilix has quit [Ping timeout: 245 seconds]
tdy has joined #ruby
mtkd has quit []
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jrafanie has joined #ruby
jrafanie has quit [Client Quit]
jrafanie has joined #ruby
jrafanie has quit [Client Quit]
chouhoulis has quit [Remote host closed the connection]
chouhoulis has joined #ruby
coderphive has quit [Quit: coderphive]
dviola has quit [Ping timeout: 260 seconds]
jenrzzz_ has quit [Ping timeout: 245 seconds]
chouhoulis has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
amelliaa has joined #ruby
amar has quit [Remote host closed the connection]
plexigras has quit [Ping timeout: 240 seconds]
kmurphy4 has joined #ruby
GodFather has joined #ruby
amar has joined #ruby
plexigras has joined #ruby
minimalism has quit [Quit: minimalism]
amar has quit [Ping timeout: 252 seconds]
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
alfiemax has joined #ruby
alfiemax has quit [Ping timeout: 245 seconds]
Mia has quit [Read error: Connection reset by peer]
regedit has joined #ruby
[Butch] has quit [Quit: Textual IRC Client: www.textualapp.com]
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eckhardt has joined #ruby
eckhardt has quit [Client Quit]
AgentVenom has quit [Quit: Textual IRC Client: www.textualapp.com]
XB23 has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
cagomez has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
nkh^ has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
t0xik has quit [Quit: Connection closed for inactivity]
orbyt_ has joined #ruby
jenrzzz has joined #ruby
alfiemax has joined #ruby
ramfjord has quit [Ping timeout: 252 seconds]
alfiemax has quit [Ping timeout: 260 seconds]
mlkkk has joined #ruby
ramfjord has joined #ruby
RyanMcCoskrie has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
moei has quit [Quit: Leaving...]
amelliaa has quit [Quit: -]
RyanMcCoskrie has quit [Remote host closed the connection]
jenrzzz has joined #ruby
RyanMcCoskrie has joined #ruby
joro_ has quit [Quit: Leaving]
nkh^ has quit [Ping timeout: 245 seconds]
quobo has quit [Quit: Connection closed for inactivity]
alfiemax has joined #ruby
nkh^ has joined #ruby
raul782 has joined #ruby
dviola has joined #ruby
alfiemax has quit [Ping timeout: 256 seconds]
Axy has joined #ruby
Axy has joined #ruby
Axy has quit [Changing host]
Mia has quit [Ping timeout: 252 seconds]
herbmillerjr has quit [Quit: Konversation terminated!]
ramfjord has quit [Ping timeout: 240 seconds]
mlkkk has quit [Remote host closed the connection]
mlkkk has joined #ruby
ramfjord has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
XB23 has quit [Remote host closed the connection]
jenrzzz has joined #ruby
mlkkk has quit [Ping timeout: 245 seconds]
ramfjord has quit [Ping timeout: 245 seconds]
venmx has joined #ruby
ramfjord has joined #ruby
pastorinni has joined #ruby
Dbugger has quit [Ping timeout: 245 seconds]
nkh^ has quit [Ping timeout: 245 seconds]
<Radar> Brainstrust: If I have an array like [1,2,2,3,4] and I want to take away [2,4], but then end up with [1,2,3], what's the trick?
<eam> do you always want to remove the first duplicate? I think I'd have to write a method
sanscoeur has quit [Ping timeout: 245 seconds]
<Radar> I want something like [1,2,2,3,4] - [2,4], but without it removing both 2s.
<Radar> > [1,2,2,3,4] - [2,4],
<Radar> >> [1,2,2,3,4] - [2,4]
<ruby[bot]> Radar: # => [1, 3] (https://eval.in/1008428)
moei has joined #ruby
zapata has quit [Ping timeout: 256 seconds]
GodFather has quit [Remote host closed the connection]
RyanMcCoskrie has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
stairmast0r has quit [Ping timeout: 256 seconds]
venmx has quit [Ping timeout: 260 seconds]
gix- has quit [Quit: Client exiting]
stairmast0r has joined #ruby
vas_ has joined #ruby
ramfjord has quit [Ping timeout: 264 seconds]
kmurphy4 has quit [Quit: kmurphy4]
jenrzzz has quit [Ping timeout: 252 seconds]
ramfjord has joined #ruby
BTRE has quit [Quit: Leaving]
<baweaver> Radar: sets potentially with a pop action.
<eam> I think I'd iterate the first array and for each item iterate the second array, removing from both on match
nitric_ has quit [Ping timeout: 248 seconds]
ramfjord has quit [Ping timeout: 240 seconds]
<Radar> One of the people here came up with: second.each { |t| first.delete_at(first.index(t)) }
<Radar> I suggested: (a & b).each { |t| a.delete_at(a.index(t)) }, just so you're not needlessly iterating through elements that don't exist in a.
<Radar> But I am not sure if that is worth any timesavings or if it's just fancy for the sake of fancy.
<baweaver> >> def delete_first(array, set) ns = Set.new(set); array.reject { |v| ns.include?(v).tap { ns.delete(v) }} end; delete_first([1,2,2,3,4], [2,4])
<ruby[bot]> baweaver: # => uninitialized constant Set (NameError) ...check link for more (https://eval.in/1008429)
<baweaver> >> require 'set'; def delete_first(array, set) ns = Set.new(set); array.reject { |v| ns.include?(v).tap { ns.delete(v) }} end; delete_first([1,2,2,3,4], [2,4])
<ruby[bot]> baweaver: # => [1, 2, 3] (https://eval.in/1008430)
gix has joined #ruby
ramfjord has joined #ruby
<Radar> Good to know that I'm not overlooking a potential built-in method to do this.
Mike11 has quit [Quit: Leaving.]
<baweaver> It deals with two distinct collections, so not really one out there
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
BTRE has joined #ruby
vulgrin has quit [Read error: Connection reset by peer]
vulgrin has joined #ruby
lxsameer has quit [Ping timeout: 245 seconds]
samort7 has quit [Read error: Connection reset by peer]
<baweaver> If they're both sorted though you could potentially make it faster.
ramfjord has quit [Ping timeout: 245 seconds]
<baweaver> then it's a matter of moving an index pointer instead of mutating a deletion set
ipe has quit [Quit: Leaving]
<baweaver> >> def sorted_first_reject(as, ns) p=0; as.reject { |a| ns[p] == a && p += 1 } end; sorted_first_reject([1,2,2,3,4], [2,4])
<ruby[bot]> baweaver: # => [1, 2, 3] (https://eval.in/1008433)
orbyt_ has quit [Ping timeout: 240 seconds]
<eam> aren't those going to barf when there are multiple repeats in the second array?
<eam> gotta iron out the semantics -- is it only ever removing the first instance and is the second array unique?
shinnya has joined #ruby
pastorinni has quit [Remote host closed the connection]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
ldnunes has quit [Quit: Leaving]
AJA4350 has quit [Quit: AJA4350]
jamesaxl has joined #ruby
kmurphy4 has joined #ruby
nicesignal has quit [Remote host closed the connection]
alfiemax has joined #ruby
nicesignal has joined #ruby
pabs has quit [Ping timeout: 252 seconds]
pabs has joined #ruby
alfiemax has quit [Ping timeout: 252 seconds]