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]
<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).
<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
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
<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
<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]
<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?
<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>
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)
<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…]
<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]