havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.3, 2.5.5, 2.7.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
skryking has quit [Ping timeout: 245 seconds]
skryking has joined #ruby
ramfjord has joined #ruby
tdy has joined #ruby
millerti has joined #ruby
duderonomy has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
elphe has quit [Ping timeout: 244 seconds]
elphe has joined #ruby
tdy has quit [Ping timeout: 248 seconds]
Tempesta has quit [Quit: AdiIRC is updating to v3.6 Beta Build (2019/08/12 UTC) 64 Bit]
Tempesta has joined #ruby
dviola has joined #ruby
millerti has quit [Ping timeout: 248 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 245 seconds]
AJA4351 is now known as AJA4350
Swyper has joined #ruby
tdy has joined #ruby
code_zombie has joined #ruby
joast has quit [Ping timeout: 245 seconds]
ramfjord has quit [Ping timeout: 272 seconds]
paraxial28 has joined #ruby
paraxial2 has quit [Ping timeout: 245 seconds]
duderonomy has quit [Ping timeout: 248 seconds]
troulouliou_dev has quit [Remote host closed the connection]
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bruce_lee has quit [Ping timeout: 246 seconds]
bruce_lee has joined #ruby
henninb has joined #ruby
Technodrome has joined #ruby
maxdoubt has quit [Quit: maxdoubt]
elphe has quit [Ping timeout: 245 seconds]
cd has quit [Ping timeout: 268 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
Fusl has quit [Excess Flood]
Fusl has joined #ruby
AJA4350 has quit [Quit: AJA4350]
Swyper has quit [Remote host closed the connection]
kyrylo has joined #ruby
elphe has joined #ruby
henninb has quit [Quit: Lost terminal]
sgen has quit [Ping timeout: 264 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
cd has joined #ruby
jenrzzz has joined #ruby
brool has quit [Ping timeout: 252 seconds]
grilix has quit [Ping timeout: 246 seconds]
tsujp has joined #ruby
Swyper has joined #ruby
ramfjord has joined #ruby
ramfjord has quit [Ping timeout: 268 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
tsujp has quit [Quit: Textual IRC Client: www.textualapp.com]
bitwinery has joined #ruby
tsujp has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 248 seconds]
jenrzzz has joined #ruby
za1b1tsu has joined #ruby
bitwinery has quit [Ping timeout: 248 seconds]
Azure has quit [Ping timeout: 248 seconds]
bitwinery has joined #ruby
Azure has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
fredolinhares has quit [Quit: WeeChat 1.9.1]
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
ur5us has quit [Ping timeout: 248 seconds]
lalitmee has joined #ruby
glosoli has joined #ruby
Azure has quit [Quit: Textual IRC Client: www.textualapp.com]
GodFather has quit [Ping timeout: 268 seconds]
GodFather_ has quit [Ping timeout: 272 seconds]
daniel has joined #ruby
daniel has quit [Client Quit]
code_zombie has quit [Quit: Leaving]
Flyingdog has joined #ruby
D9 has quit [Ping timeout: 268 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
kyrylo has quit [Client Quit]
reber has joined #ruby
ramfjord has joined #ruby
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
giraffe has quit [Quit: ZNC - http://znc.in]
tpendragon has quit [Quit: ZNC - http://znc.in]
kyrylo_ has joined #ruby
kyrylo_ has quit [Read error: Connection reset by peer]
glosoli has quit [Ping timeout: 245 seconds]
ramfjord has quit [Ping timeout: 248 seconds]
dionysus69 has joined #ruby
_whitelogger has joined #ruby
_whitelogger has joined #ruby
moei has joined #ruby
sagax has quit [Remote host closed the connection]
duderonomy has joined #ruby
levifig has quit [Ping timeout: 244 seconds]
duderonomy has quit [Client Quit]
rheddry has joined #ruby
sauvin has joined #ruby
ellcs1 has joined #ruby
dviola has quit [Quit: WeeChat 2.5]
fphilipe_ has quit [Ping timeout: 268 seconds]
aupadhye has joined #ruby
elphe has quit [Ping timeout: 272 seconds]
ellcs1 has quit [Ping timeout: 264 seconds]
duderonomy has joined #ruby
lxsameer has joined #ruby
corellian has joined #ruby
rheddry has quit [Quit: Farewell]
kyrylo has joined #ruby
levifig has joined #ruby
elphe has joined #ruby
TomyWork has joined #ruby
ur5us has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 258 seconds]
suukim has joined #ruby
GodFather has joined #ruby
GodFather_ has joined #ruby
TomyWork has quit [Ping timeout: 246 seconds]
lalitmee has quit [Ping timeout: 258 seconds]
za1b1tsu has quit [Remote host closed the connection]
cd has quit [Ping timeout: 246 seconds]
bitwinery has quit [Quit: Leaving]
fphilipe_ has joined #ruby
ramfjord has joined #ruby
ramfjord has quit [Ping timeout: 244 seconds]
deepredsky has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
queip has quit [Ping timeout: 272 seconds]
deepredsky has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
baojg has joined #ruby
<baojg> Hi, bug_db[project_name][ticket_id] = {title => title, 'due date' => t, note => description}, I wannt use 'due data' name as hash key, but it have blank char, is it correct to use here?
<baojg> due date as key name.
vondruch has quit [Quit: vondruch]
lalitmee has joined #ruby
deepredsky has joined #ruby
vondruch has joined #ruby
queip has joined #ruby
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
<phaul> baojg: what do you mean by key name? I think there is a misunderstanding in this here. Do you mean if it could be converted to a symbol? The answer is yes. it can be.
<phaul> &>> :'due date'
<rubydoc> # => :"due date" (https://carc.in/#/r/7e3l)
duderonomy has quit [Client Quit]
<muhaha> anyone knows omniauth ?
jefffrails35 has joined #ruby
<phaul> &>> {'due date': 123} # the rocket syntax reveals that it's just a symbol as a key. the postfix : is just a shorthand for symbol keys..
<rubydoc> # => {:"due date"=>123} (https://carc.in/#/r/7e3m)
jefffrails35 has quit [Client Quit]
ur5us has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
TomyWork has joined #ruby
Pascal has quit [Quit: WeeChat 2.6-dev]
Pascal has joined #ruby
Pascal is now known as r3m
kyrylo has joined #ruby
GodFather_ has quit [Ping timeout: 246 seconds]
GodFather has quit [Ping timeout: 246 seconds]
kyrylo has quit [Read error: Connection reset by peer]
drnerdius has joined #ruby
Yxhuvud has quit [Ping timeout: 264 seconds]
nowhere_man has joined #ruby
Yxhuvud has joined #ruby
Swyper has quit [Remote host closed the connection]
Tuor has joined #ruby
jefffrails35 has joined #ruby
jefffrails35 has quit [Client Quit]
kyrylo has joined #ruby
nowhere_man has quit [Ping timeout: 245 seconds]
Skarlso has quit [Quit: The Lounge - https://thelounge.chat]
Skarlso has joined #ruby
lalitmee has quit [Quit: Leaving]
<Tuor> I just build a (little) gem. I can use it. I have a script as example usage in my projects bin folder. Does this example script get into the gem or only my code in lib? If I give my built gem (.gem) to someone can he use my example usage script? If yes, how?
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
drnerdius has quit [Read error: No route to host]
drnerdius has joined #ruby
ur5us has quit [Ping timeout: 246 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
<ytti> Tuor, maybe do something like this gem.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
<ytti> Tuor, gem.executables %w[bin1 bin2 bin3]
Frobozz has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 248 seconds]
tdy has quit [Ping timeout: 245 seconds]
<Tuor> Ah nice is working. Thx.
jenrzzz has joined #ruby
drnerdius has quit [Quit: Konversation terminated!]
drnerdius has joined #ruby
TomyWork has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
drnerdius has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 244 seconds]
jenrzzz has joined #ruby
Bish has joined #ruby
<Bish> how do i split an array to some condition?
<Bish> > "one\ntwo\ntree".lines.split(/^one/)
al2o3-cr has quit [Ping timeout: 246 seconds]
<Bish> surely could do that with inject
<Bish> but i wonder if there is a better way
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 272 seconds]
davor has quit [Ping timeout: 244 seconds]
davor has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
bmurt has joined #ruby
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
TomyWork has joined #ruby
<ytti> Bish, it's not clear to me what you want to do
<Bish> basicially
<Bish> .each_with_object([[]]) { |acc,e| if condition then acc << []; acc << e }
<Bish> there must be a method like that
Nicmavr has quit [Read error: Connection reset by peer]
<Bish> .each_with_object([[]]) { |acc,e| if condition then acc << [] end; acc << e }
<Bish> rather
<ytti> perhaps give input and desired output
tpanarch1st has joined #ruby
Nicmavr has joined #ruby
grilix has joined #ruby
<ytti> perhaps Enumerable#partition but unsure
<ytti> would need to understand better what you need
elphe has quit [Ping timeout: 248 seconds]
<ytti> &>> (1..10).partition(&:odd?)
<rubydoc> # => [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]] (https://carc.in/#/r/7e4h)
elphe has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
baojg_ has joined #ruby
jenrzzz has joined #ruby
AJA4350 has joined #ruby
baojg has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 245 seconds]
baojg_ has quit [Ping timeout: 245 seconds]
Swyper has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
vondruch has quit [Ping timeout: 246 seconds]
<Bish> partition does only 2, but i want it like String#split
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
<phaul> &>> [1,2,3,1,2,2,2,1].slice_before(1).map {|a| a[1..]} # Bish
<rubydoc> # => [[2, 3], [2, 2, 2], []] (https://carc.in/#/r/7e52)
<phaul> although it break if it doesn't start with the delimiter item
<phaul> breaks*
jenrzzz has quit [Ping timeout: 244 seconds]
drnerdius has joined #ruby
yokel has quit [Ping timeout: 248 seconds]
yokel has joined #ruby
jenrzzz has joined #ruby
sagax has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
Frobozz has joined #ruby
lucasb has joined #ruby
davor_ has joined #ruby
davor has quit [Ping timeout: 245 seconds]
davor_ is now known as davor
quazimodo has joined #ruby
tsujp has joined #ruby
grilix has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
impermanence has joined #ruby
drnerdius has quit [Read error: Connection reset by peer]
jbeaudoin_sher has joined #ruby
drnerdius has joined #ruby
aupadhye has quit [Ping timeout: 248 seconds]
bmurt has joined #ruby
involans has joined #ruby
brool has joined #ruby
lupine has quit [Remote host closed the connection]
krasnus has quit [Ping timeout: 250 seconds]
EvilJStoker has quit [Ping timeout: 250 seconds]
EvilJStoker has joined #ruby
lupine has joined #ruby
krasnus has joined #ruby
sgen has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
dionysus69 has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
joast has joined #ruby
dionysus69 has joined #ruby
alem0lars has joined #ruby
alem0lars has quit [Max SendQ exceeded]
alem0lars has joined #ruby
grilix has joined #ruby
stryek has joined #ruby
involans has quit [Quit: involans]
involans has joined #ruby
rainmanj_ has joined #ruby
jinie has quit [Ping timeout: 246 seconds]
jinie has joined #ruby
rainmanjam has quit [Ping timeout: 264 seconds]
rainmanj_ has quit []
reber_ has joined #ruby
reber has quit [Ping timeout: 272 seconds]
vondruch has joined #ruby
sgen has quit [Ping timeout: 264 seconds]
<havenwood> &>> [1,2,3,1,2,2,2,1].slice_after(1).to_a
<rubydoc> # => [[1], [2, 3, 1], [2, 2, 2, 1]] (https://carc.in/#/r/7e5r)
baojg has joined #ruby
cthulchu has joined #ruby
Din_ has joined #ruby
Tuor has quit [Quit: Konversation terminated!]
Din_ has quit [Quit: Textual IRC Client: www.textualapp.com]
vondruch has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
aupadhye has joined #ruby
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
drnerdius has quit [Quit: Konversation terminated!]
kyrylo has joined #ruby
darcy has joined #ruby
<vdl> considering an array of strings ["foo", "bar", "baz"],how can I loop over all elements in the array? So that a variable equals "bar", then "baz", then "foo", ...
<also_uplime> use .each
<also_uplime> &>> ["foo", "bar", "baz"].each {|val| p val}
<rubydoc> # => "foo" (https://carc.in/#/r/7e5x)
<vdl> not enough. If s="bar", next(s) must be "baz", then next(s) must be "foo", and so on.
<also_uplime> what are you trying to do? the array you showed isn't the same order you're requesting
<also_uplime> specifying*
<vdl> looping over an array of states name
<vdl> maybe with modulo and the index of a value?
<leftylink> is it not the case that you are rotating the array?
<vdl> What I want is a variable which iterates over "foo", "bar", "baz", "foo", "bar", "baz", "foo", "bar", and so on.
<leftylink> then you are asking for a cycle.
<leftylink> its name is #cycle
dionysus70 has joined #ruby
englishm has quit [Excess Flood]
<vdl> doesn't look like what I need
englishm has joined #ruby
englishm has quit [Excess Flood]
<vdl> if you want, s++ must iterate over the array, that's all
corellian has quit [Quit: leaving]
englishm has joined #ruby
<darcy> &>> ["foo", "bar", "baz"].cycle {|val| p val}
<rubydoc> # => "foo" (https://carc.in/#/r/7e5y)
<havenwood> &>> >> ["foo", "bar", "baz"].cycle.size
<rubydoc> stderr: -e:2: syntax error, unexpected >> (https://carc.in/#/r/7e5z)
<havenwood> &>> ["foo", "bar", "baz"].cycle.size
<rubydoc> # => Infinity (https://carc.in/#/r/7e60)
<vdl> nah, ["foo", "bar", "baz"].cycle {|val| p val} prints infinitely...
<leftylink> there you go then
<havenwood> vdl: How long do you want to print?
<leftylink> exactly what you wanted
<vdl> leftylink: no, told you.
<vdl> ok let me try to be clearer
Frobozz_ has joined #ruby
darkf has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
Xiti has quit [Quit: Xiti]
Frobozz has quit [Ping timeout: 244 seconds]
chalkmonster has joined #ruby
cthu| has joined #ruby
LtHummus has quit [Read error: Connection reset by peer]
quazimodo has quit [Ping timeout: 245 seconds]
LtHummus has joined #ruby
quazimodo has joined #ruby
<vdl> Ruby being Ruby, I expect something smaller and less retard than my state_after method here: http://ix.io/1RwX
morozovm has joined #ruby
cthulchu has quit [Ping timeout: 250 seconds]
jenrzzz has joined #ruby
deepredsky has quit [Ping timeout: 244 seconds]
alem0lars has quit [Ping timeout: 268 seconds]
elphe has quit [Ping timeout: 245 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
dviola has joined #ruby
LtHummus has quit [Ping timeout: 246 seconds]
<darcy> &>> ['foo', 'bar', 'baz'].rotate.cycle{|v| p v; sleep 1}
<rubydoc> # => "bar" (https://carc.in/#/r/7e65)
elphe has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
<darcy> actually your sample starts at 'baz', so...
kyrylo has joined #ruby
<darcy> &>> ['foo', 'bar', 'baz'].rotate(2).cycle{|v| p v}
<rubydoc> # => "baz" (https://carc.in/#/r/7e69)
jenrzzz has quit [Ping timeout: 258 seconds]
jenrzzz has joined #ruby
Xiti has joined #ruby
<vdl> I just need a method to iterate. I never said I wanted to print. #cycle is completely useless. What I need is exactly what is doing the state_after method. I just know that it can be written smarter. Forget about it guys...
hutch has joined #ruby
<also_uplime> you know that the printing isn't a part of the cycling right? thats just to show it cycling
jenrzzz has quit [Ping timeout: 272 seconds]
TomyWork has quit [Ping timeout: 246 seconds]
TomyWork has joined #ruby
<darcy> vdl: your code sample prints
<vdl> it cycles indefinitely, I don't want that. Just look at what state_after does. I don't know what else to tell you.
<vdl> darcy: forget about it ;-)
<darcy> vdl: oh you want *only* what the state_after method does
jenrzzz has joined #ruby
<havenwood> &>> STATES = %w[foo bar baz].freeze; STATES.zip(STATES.rotate).to_h.freeze
<rubydoc> # => {"foo"=>"bar", "bar"=>"baz", "baz"=>"foo"} (https://carc.in/#/r/7e6t)
lypsis has joined #ruby
<vdl> darcy: that's what I asked for, yes. I even provide a (dirty) working example for you to understand. The loop/print was simply there to showcase how to use the method...
aupadhye has quit [Quit: Leaving]
<canton7> vdl, your original question was "considering an array of strings ["foo", "bar", "baz"],how can I loop over all elements in the array? So that a variable equals "bar", then "baz", then "foo", ...". It sounds like that wasn't actually your question -- in that case, it's worth being clear that your original question is incorrect, otherwise people will
<canton7> still answer based in part on your original question
lypsis_ has quit [Ping timeout: 245 seconds]
kyrylo has quit [Read error: Connection reset by peer]
fphilipe_ has quit [Ping timeout: 244 seconds]
lord4163 has quit [Excess Flood]
kyrylo has joined #ruby
morozovm has quit []
<darcy> vdl: def state_after(current_state); STATES[(STATES.find_index(current_state)+1) % STATES.size]; end
lord4163 has joined #ruby
* canton7 likes havenwood's solution
<vdl> darcy: #find_index != #index ?
fphilipe_ has joined #ruby
<darcy> vdl: they're aliases? dunno, found it by searching 'find index'
elphe has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
* darcy likes Havenwood's solution better as well... just creates a map, no searching needed
_serenity has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
fphilipe_ has quit [Read error: Connection reset by peer]
dionysus70 has quit [Remote host closed the connection]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
woo has joined #ruby
<woo> Hi
hutch has quit [Ping timeout: 248 seconds]
<woo> anyone knows how to solve this error: http://dpaste.com/2B9F1RZ.txt
<woo> ?
jenrzzz has quit [Ping timeout: 248 seconds]
istrasci has joined #ruby
<vdl> havenwood: cannot this be chained?
<istrasci> How I list all class methods defined for a Class? I can get the instance methods with MyClass.instance_methods. But how do I get the class methods?
<darcy> istrasci Class.methods(false)
kyrylo has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
<istrasci> darcy: Thank you
woo has quit [Ping timeout: 245 seconds]
kyrylo has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
al2o3-cr has joined #ruby
al2o3-cr has quit [Client Quit]
jenrzzz has quit [Ping timeout: 244 seconds]
davor has quit [Ping timeout: 244 seconds]
davor has joined #ruby
al2o3-cr has joined #ruby
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 272 seconds]
AJA4351 is now known as AJA4350
poontangmessiah has joined #ruby
jenrzzz has joined #ruby
awayfrommypc1056 has joined #ruby
fphilipe_ has joined #ruby
awayfrommypc1056 has quit [Client Quit]
woo has joined #ruby
baojg has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 268 seconds]
<leftylink> ah, that's too bad. but it looks like the matter has been resolved
LtHummus has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.5]
GodFather_ has joined #ruby
GodFather has joined #ruby
duderonomy has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
Nowaker has quit [Ping timeout: 248 seconds]
Nowaker has joined #ruby
<woo> had some network problems.
tdy has joined #ruby
<woo> the database I'm trying to connect is mariadb.
<woo> does the mysql gem works for it?
TomyWork has quit [Ping timeout: 246 seconds]
<balo> this is the mysql2 gem
wildtrees has joined #ruby
jenrzzz has joined #ruby
alem0lars has joined #ruby
<woo> balo: thank you.
hutch has joined #ruby
glosoli has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
sh7d has quit [Ping timeout: 258 seconds]
sh7d has joined #ruby
<bhaak> how does cycle not solve that problem?
<bhaak> &>> c=['foo', 'bar', 'baz'].cycle; puts c.next; puts c.next
<rubydoc> # => foo (https://carc.in/#/r/7e7r)
<havenwood> bhaak: The problem as stated was different than the desired method behavior. ¯\_(ツ)_/¯
jenrzzz has joined #ruby
<bhaak> havenwood: yeah, I got that but the dirty solution does exactly what cycle does as well.
<bhaak> well, not cycle in itself. the Enumerator returned from cycle
<havenwood> bhaak: I'm guessing the example was artificially zoomed in, and the real use case doesn't work with #cycle. It's really hard to say without knowing what the real problem was. It'd be waaay easier for us to suggest good solutions if we knew what the real goal was.
jenrzzz has quit [Ping timeout: 246 seconds]
<havenwood> xy problem, etc
<havenwood> bhaak: I agree with you, as far as cycle is the best solution for the stated problem.
<bhaak> maybe
<havenwood> Better questions, better answers.
<bhaak> but it was claimed that the dirty code did all it should do.
<bhaak> but yeah, given the poor phrasing. who knows
jakeb3 has left #ruby [#ruby]
codefriar has quit [Ping timeout: 248 seconds]
howdoi has joined #ruby
codefriar has joined #ruby
poontangmessiah has quit [Remote host closed the connection]
alem0lars has quit [Ping timeout: 245 seconds]
darcy has quit [Remote host closed the connection]
tpanarch1st has quit [Ping timeout: 258 seconds]
davor has quit [Ping timeout: 245 seconds]
muhaha has quit [Ping timeout: 272 seconds]
davor has joined #ruby
code_zombie has joined #ruby
frem has joined #ruby
code_zombie has quit [Client Quit]
ramfjord has joined #ruby
chalkmonster has joined #ruby
code_zombie has joined #ruby
jenrzzz has joined #ruby
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
drnerdius has joined #ruby
im_saeed has joined #ruby
elphe has joined #ruby
gix has joined #ruby
darcy has joined #ruby
darcy is now known as d`arcy
elphe has quit [Ping timeout: 245 seconds]
im_saeed has quit [Remote host closed the connection]
sauvin has quit [Read error: Connection reset by peer]
im_saeed has joined #ruby
im_saeed has quit [Max SendQ exceeded]
involans has quit [Quit: involans]
im_saeed has joined #ruby
im_saeed has quit [Remote host closed the connection]
d`arcy has quit [Remote host closed the connection]
im_saeed has joined #ruby
istrasci has quit [Remote host closed the connection]
englishm has quit [Excess Flood]
chalkmonster has quit [Quit: WeeChat 2.5]
englishm has joined #ruby
d`arcy has joined #ruby
Frobozz_ is now known as Frobozz
im_saeed has quit [Quit: Leaving]
hiroaki has quit [Ping timeout: 248 seconds]
chalkmonster has joined #ruby
suukim has quit [Quit: Konversation terminated!]
<havenwood> _serenity: What's the meaning of this!?
<_serenity> i just left the client open for a few hours and no one said anything just joins/leaves
conta1 has joined #ruby
<havenwood> _serenity: Maybe hide joins and leaves?
<havenwood> _serenity: We're all just waiting for someone to have a Ruby question. Apparently the docs are too good. :P
<_serenity> my point was that there was nothing else
<havenwood> _serenity: Do you have a Ruby question?
<havenwood> Nobody seems to...
<_serenity> well as it happens i do, not that i joined with the intention of asking it but maybe you know the answer
<_serenity> how is that returning from a block is a valid operation
<_serenity> is it because blocks envoke methods so you return from that method?
<_serenity> if so what are the practical uses of that if any
<phaul> a return in a block feels quite natural to me especially that local variables ripple through block boundaries, so blocksare really not like anonymous functions
<_serenity> right but why is it possible to return from a block, what is actually going on?
<phaul> it's a closure passed as an argument, while the receiver is running the block of code it can set where the return should return as part of the environment
<phaul> I mean the caller can set whereb it should return along with the environment. sorry
hiroaki has joined #ruby
<_serenity> so it is a return from the envoked method? as in `10.times {|i| return}` would return from Integer#times
<phaul> no. think of it as just giving you a tool to define your own control structures. It returns from where it lexically appears
<phaul> controlstructures like if else, for while until...
<havenwood> _serenity: That would return from the enclosing method. Outside a method, it would be a LocalJumpError
<havenwood> &>> def foo; 10.times {|i| return i}; 42 end; foo
<rubydoc> stderr: /home/carcin/carcin/sandboxes/ruby/sandboxed_ruby2.6.0: error while loading shared libraries:... check link for more (https://carc.in/#/r/7e83)
<havenwood> &>> def foo; 10.times {|i| return i}; 42 end; foo
<rubydoc> stderr: /home/carcin/carcin/sandboxes/ruby/sandboxed_ruby2.6.0: error while loading shared libraries:... check link for more (https://carc.in/#/r/7e84)
<havenwood> #=> 0
<_serenity> notice how i didnt use a method
<havenwood> _serenity: LocalJumpError
<_serenity> no
<havenwood> _serenity: The locality of return does vary between procs, blocks and lambdas. Ruby doesn't violate Tennet's correspondence principle.
<havenwood> yes
<havenwood> Anyways, meeting. ;P
drnerdius has quit [Read error: Connection reset by peer]
drnerdius has joined #ruby
<leftylink> whhat is this correspondence principle
<_serenity> &>> 10.times {|i| return}
<rubydoc> stderr: /home/carcin/carcin/sandboxes/ruby/sandboxed_ruby2.6.0: error while loading shared libraries:... check link for more (https://carc.in/#/r/7e85)
<havenwood> #!> LocalJumpError: unexpected return # _serenity
involans has joined #ruby
<_serenity> ruby 2.6.3 runs that silently
<phaul> it seems that carc.in has been updated, and got broken. 24 version works
<_serenity> there is no error
<phaul> &24>> 1 + 1
<rubydoc> # => 2 (https://carc.in/#/r/7e89)
<_serenity> &24>> 10.times {|i| return}
<rubydoc> stderr: -e:2:in `block in <main>': unexpected return (LocalJumpError) (https://carc.in/#/r/7e8a)
<_serenity> &24>> puts `ruby -v`
<rubydoc> # => ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] (https://carc.in/#/r/7e8b)
<_serenity> im running a different version
<_serenity> so what changed
<phaul> nothing. 2.6.3 also LocalJumpErrors the same way
<_serenity> no it does not
<phaul> except ofc if it appears inside a def
codefriar has quit [Ping timeout: 246 seconds]
<_serenity> okay so it doesnt LocalJumpError, this is the code: `10.times {|i| return}`
<_serenity> so whats going on
<_serenity> &24>> p [1, 2, 3, 4, 5].detect { |number| number.even? }
<rubydoc> # => 2 (https://carc.in/#/r/7e8d)
<phaul> and where does that have a return in a block?...
<_serenity> the {} encloses a block
<phaul> yeah, I thought the discussion was about "return" literaly appearing inside blocks
Eiam has quit [Read error: Connection reset by peer]
<_serenity> does it matter if you use the keyword or not?
<phaul> it does
<_serenity> only if you're not returning from the bottom of the block i would have thought
<phaul> &24>> p [1, 2, 3, 4, 5].detect { |number| return number.even? }
<rubydoc> stderr: -e:2:in `block in <main>': unexpected return (LocalJumpError) (https://carc.in/#/r/7e8e)
chalkmonster has quit [Ping timeout: 245 seconds]
<phaul> it's useful to think of a block likea user defined flow control
<phaul> like while/until loop etc
<phaul> it's the same jump error as this one:
<phaul> &24>> return if true
<rubydoc> stderr: -e:3: void value expression (https://carc.in/#/r/7e8f)
kyrylo has joined #ruby
<phaul> almost.. :) , anyways. it was here on 2.6.3
gb_away has joined #ruby
ixti has joined #ruby
<phaul> or just simply:
<phaul> &24>> return
<rubydoc> stderr: -e:3: void value expression (https://carc.in/#/r/7e8g)
<_serenity> on 2.6.3 im getting no output when using `return` and 2 as output when not using `return`
<_serenity> with this: `p [1, 2, 3, 4, 5].detect {|number| number.even?}`
kyrylo has quit [Read error: Connection reset by peer]
<_serenity> does the `return` cause it to exit prematurely
kyrylo has joined #ruby
<leftylink> `return` exits the lexically enclosing function. perhaps I don't know you are interested in something like
<leftylink> &24>> def f(a); a.map { |x| return :actually_the_whole_thing_is_invalid if x == 7; x * 10 } end; p [f([1, 2, 3]), f([1, 4, 7, 10])]
<rubydoc> # => [[10, 20, 30], :actually_the_whole_thing_is_invalid] (https://carc.in/#/r/7e8h)
<leftylink> maybe you just really don't like the number 7 for some reason
<_serenity> i see, but then what is the difference between explicitly using `return` and just supplying a return value at the end of the block? i always thought it was just sugar and the intepreter assumed a return
<phaul> oh I know why the weird void value errors from the bot... the bots addition of begin..end screws up things
<leftylink> well, the `x * 10` demonstrates what happens if you don't use the `return` keywordc, doens't it?
<leftylink> &24>> def f(a); a.map { |x| x * 10 } end; p [f([1, 2, 3]), f([1, 4, 7, 10])]
<rubydoc> # => [[10, 20, 30], [10, 40, 70, 100]] (https://carc.in/#/r/7e8i)
<leftylink> in that case, you do not prematurely exit from `f`
<leftylink> so that is very different
<_serenity> yeah i saw that but what is the difference
<_serenity> besides the inclusion of `return`
<leftylink> where did 10 and 40 go in theh first example?
<leftylink> where is 100?
<leftylink> why is the result a symbol instead of an array?
<_serenity> because you are returning from f()
<leftylink> great
<_serenity> but what about if it wasnt enclosed in a function
kyrylo has quit [Read error: Connection reset by peer]
<phaul> then LocalJumpError. We are going around in circles ...
kyrylo has joined #ruby
<_serenity> when not using `return`
grilix has quit [Ping timeout: 258 seconds]
<_serenity> this `p [1, 2, 3, 4, 5].detect {|number| number.even?}` outputs 2
<_serenity> this `p [1, 2, 3, 4, 5].detect {|number| return number.even?}` has no output
<_serenity> from stdout or stderr
<_serenity> on 2.6.3
<phaul> the latter does print the exception here on 2.6.3 as it should.
<phaul> ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
<phaul> repl is the stock irb
<_serenity> im using the interpreter natively and its not showing any exception
lxsameer has quit [Ping timeout: 246 seconds]
<phaul> yeah. try it in a repl
<phaul> or catch exceptions to see if there were any
<leftylink> note that if you do `return; puts :hello`, hello is not output. therefore, same with `p [1, 2, 3, 4, 5].detect {|number| return number.even?}` , you should not expect that anything was output.
<_serenity> but why does it raise an exception on older versions
<ixti> Hi, all! I've ran into a weird behavior of `Array#each`. Can't make a short snippet that reproduces it, but it happens regular in production for us.
<baweaver> ixti: Doesn't really give us much to go on
<_serenity> ^
desperek has joined #ruby
<baweaver> The first step to debugging is reproduction
<ixti> Sorry I thought I'll be able to describe the problem in second message before getting the reply :D
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
tdy has quit [Ping timeout: 245 seconds]
jakeb2 has left #ruby [#ruby]
<leftylink> it would be an exception in older versions because top-level return was not added until 2.4, right? https://bugs.ruby-lang.org/issues/4840
<_serenity> if its taking you that long to type then use https://pastebin.com/
<_serenity> thank you, leftylink that was the explanation i was lookingfor
kyrylo has quit [Read error: Connection reset by peer]
<baweaver> dpaste.de is preferred, less ads and shenanigans
kyrylo has joined #ruby
<_serenity> didnt know about dpaste.de, nice
jenrzzz has quit [Ping timeout: 258 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
<ixti> If would be able to reproduce the error - most likely I would not need a help. The problem that it happens in production and I can't nail down the root cause, so I feel like I'm missing something...
<ixti> So, we use sidekiq, and the job looks like ^^^
<ixti> And sometimes, it fails with *undefined local variable or method \`step_options'*
<ixti> (i've updated gist just now - initial upload contained a typo)
kyrylo has quit [Read error: Connection reset by peer]
<ixti> In other words, somehow, under some circumstances `step_options` becomes undefined within `STEPS.each { |step_options| ... }` loop
kyrylo has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
<ixti> For now we solved the problem by replacing `STEPS.each` with `STEPS.dup.each`.
sameerynho has joined #ruby
<ixti> But I would like to know if that's known behavior
jenrzzz has joined #ruby
AJA4350 has quit [Ping timeout: 248 seconds]
jenrzzz has quit [Ping timeout: 246 seconds]
kyrylo has quit [Read error: Connection reset by peer]
codefriar has joined #ruby
kyrylo has joined #ruby
queip has quit [Ping timeout: 246 seconds]
involans_ has joined #ruby
involans has quit [Read error: Connection reset by peer]
Technodrome has joined #ruby
_serenity has left #ruby ["WeeChat 2.5"]
Technodrome has quit [Remote host closed the connection]
kyrylo has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
kyrylo has joined #ruby
involans_ has quit [Ping timeout: 248 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
conta1 has quit [Quit: conta1]
d`arcy has quit [Remote host closed the connection]
troulouliou_div2 has joined #ruby
grilix has joined #ruby
<glosoli> what is the most typical data format ruby devs store configs that are prone to change over the time?
<bhaak> YAML?
<glosoli> thanks
SeepingN has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
<leftylink> interesting. I had thought that for `a.each { |x| ... }` that during the block `x` would surely be defined. I guess I will belearning something new today when thhe reason is figured out.
cliluw has joined #ruby
queip has joined #ruby
AJA4350 has joined #ruby
troulouliou_div2 has quit [Remote host closed the connection]
elphe has joined #ruby
ur5us has joined #ruby
glosoli has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elphe has quit [Ping timeout: 246 seconds]
impermanence has quit [Remote host closed the connection]
queip has quit [Ping timeout: 245 seconds]
SuperLag has quit [Remote host closed the connection]
phroa has quit [Remote host closed the connection]
queip has joined #ruby
tdy has joined #ruby
jenrzzz has quit [Ping timeout: 248 seconds]
jenrzzz has joined #ruby
regedit has joined #ruby
<regedit> hello
<desperek> good evening
<regedit> how do i write a file contents as a string to database, and then later load this string back from database and use it as a file?
<regedit> this particular table/column in database is 'text' so i dunno about having a dedicated binary/blob column for this purpose...
<havenwood> regedit: What do you mean by "use it as a file?"
<regedit> havenwood: ideally i could IO open it etc. using it with libraries that expect to work on a file
<regedit> so like maybe i need to write the stuff to a TempFile or something
cd has joined #ruby
<regedit> i guess i'm more concerned about the first part: someone uploads a file, i have its UploadedFile TempFile with binary content, how do i save that content as string to database for later usage
<havenwood> regedit: What's the problem with saving it to the DB? What isn't working?
<desperek> you need a driver for your database and then insert the data with it
<desperek> or just use an array
<desperek> or maybe dont
SuperLag has joined #ruby
<regedit> ehm... i guess i havent tried 🤔 perhaps i was preemptively worried that if i do that it might explode on unexpected binary bytes when it expected sane string data... like maybe when it tries binding the data into the insert statement it would mess up or something... but maybe you're right i should TIAS first
<desperek> well, you can sanitize
<regedit> i could maybe just json encode or base64 encode the file contents, but i was wondering if there's some other known way how to safely save raw file binary as string to database
<regedit> either way imma first try the naive way and see if anything wrong happens
<regedit> desperek: what kind of sanitization?
<havenwood> regedit: The issue I've run into is needing to split files across rows. It works well.
<desperek> regedit, oh well i meant like remove all characters that are not in ascii or something
<desperek> but yeah, idk about saving blobs or binary data really
<desperek> sorry
<regedit> havenwood: not sure i'll need that, in this case i THINK (hope...) the whole lot of binary content can fit in a single row text field
<havenwood> regedit: There are some caveats, so I'd reference a gem that does it.
jenrzzz has quit [Ping timeout: 272 seconds]
<regedit> havenwood: sure what's the gem
FastJack has quit [Ping timeout: 264 seconds]
desperek has quit [Quit: mew wew]
<havenwood> regedit: I don't remember. I used a paperclip-like thing with Postgres.
Nicmavr has quit [Read error: Connection reset by peer]
<regedit> i see ok
aphprentice__ has joined #ruby
Nicmavr has joined #ruby
kaleido has quit [Remote host closed the connection]
kaleido has joined #ruby
FastJack has joined #ruby
jenrzzz has joined #ruby
cthulchu has joined #ruby
cthu| has quit [Ping timeout: 250 seconds]
jenrzzz has quit [Ping timeout: 248 seconds]
tdy has quit [Ping timeout: 248 seconds]
kaleido has quit [Remote host closed the connection]
kaleido has joined #ruby
reber_ has quit [Remote host closed the connection]
Leopere has quit [Quit: The Lounge - https://thelounge.github.io]
jenrzzz has joined #ruby
Swyper has quit [Remote host closed the connection]
<regedit> 🤔 interesting
hutch has quit [Ping timeout: 272 seconds]
AndreYuhai has joined #ruby
chalkmonster has joined #ruby
Leopere has joined #ruby
<AndreYuhai> Hey there, I have a class and I am including a module to create database tables. But for example I will need more than 2 create table methods each of them creating a different table. How can I separate them using namespaces or modules? I got a bit confused.
<AndreYuhai> I mean how can I use my create_table method like ModuleName.create_table ? Because when I make it a class method then I can not use the instance variable from the class in which I am including the module.
cthu| has joined #ruby
entel has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
<entel> >>1+1
<ruby[bot]> entel: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<entel> hm
cthulchu has quit [Ping timeout: 250 seconds]
<phaul> entel: right now you can get a working in chat repl with &24>> prefix . I know...
poontangmessiah has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.5]
<woo> hi
sameerynho has quit [Ping timeout: 258 seconds]
<regedit> havenwood: well here we have it: the specific error if i try saving file binary data to an ActiveRecord string field value: "incomplete multibyte character"
<woo> I'm having trouble loading a class. This is the code being used to lookup for ruby files: http://dpaste.com/2YFPJFX.txt
<woo> but this error pops up: http://dpaste.com/16YQ17B.txt
<woo> Base is the parent class of the one causing trouble.
<woo> but it has other children which operate normally through this same method.
<entel> &24>> 1+1
<rubydoc> # => 2 (https://carc.in/#/r/7e9t)
<entel> phaul: thanks
gix- has joined #ruby
gix has quit [Disconnected by services]
Swyper has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
poontangmessiah_ has joined #ruby
poontangmessiah has quit [Ping timeout: 272 seconds]
Swyper has quit [Ping timeout: 248 seconds]
elphe has joined #ruby
mark22k has joined #ruby
<havenwood> regedit: Does the Postgres encoding match the file? Consider Base64ing before saving to DB.
<regedit> yep trying base64-ing now...
<havenwood> regedit: I wish I had a gem link, but I'm too busy to search for it. The one I used saved to PG across rows and worked well. I'm presuming it Base64ed. I vaguely recall that it did.
elphe has quit [Ping timeout: 248 seconds]
moei has quit [Quit: Leaving...]
bvdw has joined #ruby
gb_away has quit [Quit: One disk to rule them all, One disk to bind them, One disk to hold the files And in the darkness grind 'em.]
gb_away has joined #ruby
Swyper has joined #ruby
Swyper has quit [Read error: No route to host]
troulouliou_div2 has joined #ruby
Swyper has joined #ruby
bruce_lee has quit [Ping timeout: 245 seconds]
Swyper has quit [Ping timeout: 248 seconds]
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
AndreYuhai has quit [Quit: Leaving]
RiPuk has quit [Ping timeout: 245 seconds]
AndroidKitKat has left #ruby ["WeeChat 2.5"]
troulouliou_div2 has quit [Remote host closed the connection]
quazimodo has quit [Ping timeout: 245 seconds]
mark22k has quit [Remote host closed the connection]
mark22k has joined #ruby
mark22k is now known as Guest19375
Guest19375 has quit [Remote host closed the connection]
frem has quit [Quit: Connection closed for inactivity]
chalkmonster has joined #ruby
woo has quit [Quit: leaving]
duderonomy has quit [Ping timeout: 244 seconds]
AndroidKitKat has joined #ruby
reaVer has quit [Remote host closed the connection]
AndroidKitKat has left #ruby [#ruby]
<regedit> i see oh well
<regedit> thanks either way havenwood 👍
RiPuk has joined #ruby
jenrzzz_ has joined #ruby
tdy has joined #ruby