adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 2.7.2, 2.6.6, 3.0.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.org | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | BLM <3
hiroaki has quit [Ping timeout: 264 seconds]
Swyper has quit [Ping timeout: 258 seconds]
akem has joined #ruby
hiroaki has joined #ruby
braincrash has quit [Ping timeout: 265 seconds]
stryek has quit [Quit: Connection closed for inactivity]
iamgr00t_ is now known as iamgr00t
Swyper has joined #ruby
oneeggeach has joined #ruby
<queip> if my webserver is really low on resources like RAM
<queip> can I use some kind of Ruby on monorail?
<queip> (should be faster)
oneeggeach has quit [Client Quit]
ur5us has joined #ruby
<havenwood> queip: Yeah, there are microframeworks like Roda or you can use Rack directly.
<havenwood> queip: Or there are non-Rack options.
dhollinger has quit [Ping timeout: 264 seconds]
dhollinger has joined #ruby
hiroaki has quit [Ping timeout: 272 seconds]
bsdbandit-01 has joined #ruby
hiroaki has joined #ruby
ruurd has quit [Quit: bye folks]
bsdbandit-01 has quit [Read error: Connection reset by peer]
ramfjord has quit [Ping timeout: 246 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
zenix_2k2 has joined #ruby
bsdbandit-01 has joined #ruby
<zenix_2k2> noobie question tho, is there any ggood source to learn Ruby ? usually lots of random online resources aren't very trustworthy sometime
<zenix_2k2> i am a beginner to ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
<nakilon> zenix_2k2 this page contains some https://www.ruby-lang.org/en/documentation/
<zenix_2k2> oh ok, didn't know about that
prion has quit [Ping timeout: 272 seconds]
zenix_2k2 has quit [Quit: Leaving]
mihael has joined #ruby
<mihael> Anyone using Rails and Heroku here? have you tried Getting the error SMTPAuthentication Error from SendGrid?
MeVegan[m] has quit [Ping timeout: 268 seconds]
MeVegan[m] has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
prion has joined #ruby
teardown has quit [Ping timeout: 240 seconds]
ian| has quit [Quit: Exiting]
teardown has joined #ruby
TCZ has quit [Quit: Wawel - Czujesz sie dobrze, czynisz dobrze]
aremaref has quit [Ping timeout: 246 seconds]
hiroaki has quit [Ping timeout: 268 seconds]
hiroaki has joined #ruby
drincruz has joined #ruby
prion has quit [Ping timeout: 256 seconds]
aremaref has joined #ruby
gix has quit [Ping timeout: 264 seconds]
aremaref has quit [Ping timeout: 264 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Some-body_ has joined #ruby
DarthGandalf has quit [Ping timeout: 272 seconds]
Some-body_ is now known as DarthGandalf
Technodrome has joined #ruby
duderonomy has quit [Quit: Textual IRC Client: www.textualapp.com]
ur5us has quit [Ping timeout: 264 seconds]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Swyper has quit [Ping timeout: 268 seconds]
ur5us has joined #ruby
elcuervo has joined #ruby
bsdbandit-01 has joined #ruby
cuerbot has quit [Ping timeout: 260 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
ChmEarl has quit [Quit: Leaving]
so1e[m] has joined #ruby
drincruz has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 264 seconds]
DarthGandalf has quit [Remote host closed the connection]
DarthGandalf has joined #ruby
DarthGandalf has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
meimeix has joined #ruby
aremaref has joined #ruby
aremaref has quit [Ping timeout: 240 seconds]
al2o3-cr has quit [Ping timeout: 256 seconds]
prion has joined #ruby
blackmesa has joined #ruby
naftilos76 has joined #ruby
r29v has joined #ruby
r29v has quit [Client Quit]
blackmesa1 has joined #ruby
blackmesa has quit [Ping timeout: 260 seconds]
bsdbandit-01 has joined #ruby
aremaref has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
naftilos76_ has joined #ruby
naftilos76 has quit [Ping timeout: 268 seconds]
prion has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hiroaki has quit [Ping timeout: 268 seconds]
hiroaki has joined #ruby
blackmesa1 has quit [Ping timeout: 268 seconds]
SeepingN has quit [Ping timeout: 264 seconds]
aremaref has quit [Ping timeout: 264 seconds]
orbyt_ has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
dfucci has joined #ruby
aremaref has joined #ruby
Rudd0 has quit [Ping timeout: 240 seconds]
TomyWork has joined #ruby
aremaref has quit [Ping timeout: 265 seconds]
bsdbandit-01 has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
bsdbandit-01 has quit [Read error: Connection reset by peer]
gavlee has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
blackmesa1 has joined #ruby
gypsy5[m] has quit [Quit: Idle for 30+ days]
glimpse[m] has quit [Quit: Idle for 30+ days]
naftilos76_ has quit [Quit: Leaving]
drincruz has joined #ruby
drincruz has quit [Ping timeout: 246 seconds]
nowz has quit [Quit: WeeChat 2.8]
lightstalker has quit [Ping timeout: 256 seconds]
lightstalker has joined #ruby
nofxx_ has joined #ruby
hiroaki has quit [Ping timeout: 256 seconds]
vondruch has joined #ruby
nofxx has quit [Ping timeout: 265 seconds]
akem has quit [Remote host closed the connection]
hiroaki has joined #ruby
Rudd0 has joined #ruby
jl4 has joined #ruby
<isene> Is there any way to intercept 'getc' - i.e. to tell it to no longer wait for input?
pen has joined #ruby
ramfjord has joined #ruby
baojg has quit [Remote host closed the connection]
pen has quit [Client Quit]
baojg has joined #ruby
ramfjord has quit [Ping timeout: 260 seconds]
neozor has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
fanta1 has joined #ruby
Technodrome has joined #ruby
neozor has quit []
al2o3-cr has joined #ruby
k_sze has quit [Ping timeout: 265 seconds]
Hien has quit [Ping timeout: 260 seconds]
Hien has joined #ruby
Swyper has joined #ruby
Swyper has quit [Read error: Connection reset by peer]
Swyper has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
somazero has joined #ruby
cd has quit [Quit: cd]
rubydoc has quit [Ping timeout: 240 seconds]
phaul has quit [Ping timeout: 260 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
banisterfiend has joined #ruby
weaksauce has quit [Ping timeout: 240 seconds]
lucidreamachine has joined #ruby
braincrash has joined #ruby
bsdbandit-01 has joined #ruby
banisterfiend_ has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
k_sze has joined #ruby
banisterfiend_ has quit [Client Quit]
cloud69 has joined #ruby
braincrash has quit [Ping timeout: 256 seconds]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
prion has joined #ruby
zapata has quit [Quit: WeeChat 3.0]
TCZ has joined #ruby
Axy has joined #ruby
Axy has quit [Changing host]
Axy has joined #ruby
Mia has quit [Ping timeout: 256 seconds]
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
prion has quit [Ping timeout: 268 seconds]
stonerl has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
stonerl has joined #ruby
dionysus69 has joined #ruby
lucidreamachine has quit [Ping timeout: 260 seconds]
Mia has joined #ruby
Mia has joined #ruby
Axy has quit [Ping timeout: 268 seconds]
Technodrome has joined #ruby
dionysus69 has quit [Ping timeout: 256 seconds]
TCZ has quit [Quit: Wawel - Czujesz sie dobrze, czynisz dobrze]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Mia has quit [Ping timeout: 268 seconds]
Cork has quit [Quit: .]
banisterfiend has joined #ruby
banisterfiend has quit [Read error: Connection reset by peer]
rubydoc has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
rubydoc has quit [Excess Flood]
phaul has joined #ruby
rubydoc has joined #ruby
prion has joined #ruby
jl4 has quit [Ping timeout: 272 seconds]
rubydoc has quit [Excess Flood]
rubydoc has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
rubydoc has quit [Ping timeout: 268 seconds]
banisterfiend has joined #ruby
TCZ has joined #ruby
banisterfiend has quit [Ping timeout: 268 seconds]
Swyper has quit [Remote host closed the connection]
stryek has joined #ruby
banisterfiend has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Max SendQ exceeded]
DarthGandalf has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Xiti` has joined #ruby
Technodrome has joined #ruby
Xiti has quit [Ping timeout: 260 seconds]
Swyper has joined #ruby
lucidreamachine has joined #ruby
Swyper has quit [Remote host closed the connection]
banister_ has joined #ruby
bsdband36 has joined #ruby
bsdband36 has quit [Excess Flood]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
SeepingN has joined #ruby
Cork has joined #ruby
mihael has quit [Ping timeout: 260 seconds]
mbrndtgn has quit [Quit: Ping timeout (120 seconds)]
mbrndtgn has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troll_ has joined #ruby
<troll_> ruby is bloated.
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
troll_ was banned on #ruby by adam12 [*!*@2001:ac8:20:302::202d]
troll_ was kicked from #ruby by adam12 [troll_]
Swyper has quit [Remote host closed the connection]
Axy has joined #ruby
Axy has joined #ruby
Axy has quit [Changing host]
Mia has quit [Ping timeout: 246 seconds]
hiroaki has quit [Ping timeout: 264 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Axy has quit [Ping timeout: 256 seconds]
rubydoc has joined #ruby
phaul has joined #ruby
mihael has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Excess Flood]
rubydoc has quit [Remote host closed the connection]
bsdbandit-01 has joined #ruby
rubydoc has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
hiroaki has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
lucidreamachine has quit [Ping timeout: 260 seconds]
prion has quit [Ping timeout: 246 seconds]
lucidreamachine has joined #ruby
ChmEarl has joined #ruby
Swyper has joined #ruby
banisterfiend has quit [Quit: banisterfiend]
Rudd0 has quit [Remote host closed the connection]
Rudd0 has joined #ruby
blackmesa1 has quit [Ping timeout: 268 seconds]
rubydoc has quit [Ping timeout: 240 seconds]
phaul has quit [Ping timeout: 265 seconds]
jl4 has joined #ruby
ule has quit [Ping timeout: 272 seconds]
ule has joined #ruby
Mrgoose has quit [Ping timeout: 256 seconds]
Swyper has quit [Remote host closed the connection]
Swyper_ has joined #ruby
dfucci has quit [Ping timeout: 265 seconds]
Mrgoose has joined #ruby
prion has joined #ruby
mihael has quit [Ping timeout: 268 seconds]
JasonO- has joined #ruby
naftilos76 has joined #ruby
Swyper_ has quit [Remote host closed the connection]
<naftilos76> Hi, does anybody have any idea why mysql2 gem shows 000 when strftime is configured to show milliseconds? I tried channel rubygems but there is nobody there :)
robotmay has quit [Remote host closed the connection]
Swyper has joined #ruby
robotmay has joined #ruby
<adam12> naftilos76: Code?
bsdbandit-01 has joined #ruby
TCZ has quit [Quit: Wawel - Czujesz sie dobrze, czynisz dobrze]
JasonO has quit [Excess Flood]
<naftilos76> adam12: i will be back in a while
rubydoc has joined #ruby
dfucci has joined #ruby
phaul has joined #ruby
dfucci has quit [Ping timeout: 268 seconds]
arahael has quit [Ping timeout: 260 seconds]
elcuervo has quit [Read error: Connection reset by peer]
ian| has joined #ruby
arahael has joined #ruby
<isene> Anyone? Is there any way to intercept 'getc' - i.e. to tell it to no longer wait for input?
elcuervo has joined #ruby
<adam12> isene: None that I'm aware. What about getch() with a time argument, in a loop?
<adam12> Then if you want to no longer wait, the loop is checking something which says to abort. while prompt_user?; c = getch(time: 1); end
lucidreamachine has quit [Ping timeout: 260 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
howdoi has joined #ruby
dfucci has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
braincrash has joined #ruby
ellcs has joined #ruby
lucidreamachine has joined #ruby
phaul has quit [Remote host closed the connection]
phaul has joined #ruby
<ian|> in ruby are there 'static' class variables, which... perhaps remain uniform across all instances, or tied to the Class?
<baweaver> @@class_variable = 'shared across instances'
<baweaver> but they can be touchy
<baweaver> with inheritance*
<ian|> thanks
rubydoc has quit [Remote host closed the connection]
<adam12> Agreed; I don't say _avoid_ them, but if they end up in a PR I'm reviewing, they get looked at extra carefully.
jl4 has quit [Remote host closed the connection]
rubydoc has joined #ruby
rubydoc has quit [Excess Flood]
rubydoc has joined #ruby
<ian|> i don't like how [Array.new] calls Array.new(), I would expect the function, as used as an expression, to return itself, not call it
<ian|> perhaps there is a sigil to make it return itself
<ian|> or perhaps i'm getting ruby confused with javascript, and good OOP would not permit a first-class class method to be a value
<ian|> s/first-class//
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
rubydoc has quit [Ping timeout: 264 seconds]
phaul has quit [Ping timeout: 260 seconds]
<adam12> ian|: Array()
phaul has joined #ruby
<adam12> &>> Array([])
<adam12> Maybe I'm mis-understanding what you want.
rubydoc has joined #ruby
<ian|> i was confusing ruby for a prototypal-OOP language or something.. lol
<leftylink> Array.method(:new) is what is being requested
<leftylink> which can then be called
<leftylink> &>> Array.method(:new)[1, 2, 3, 4, 5]
<rubydoc> stderr: -e:4:in `initialize': wrong number of arguments (given 5, expected 0..2) (ArgumentError)... check link for more (https://carc.in/#/r/a4e0)
<ian|> ahh... hmm
<leftylink> &>> Array.method(:new)[1]
<rubydoc> # => [nil] (https://carc.in/#/r/a4e1)
<leftylink> &>> Array.method(:new)[3] { true }
<rubydoc> # => [true, true, true] (https://carc.in/#/r/a4e2)
<isene> adam12: I'll try that. Thanks.
Petruchio has joined #ruby
<Petruchio> Hello. Anyone know a gem which expedites the routine of checking on files and permissions? E.g.: Does directory x exist? If not, create it. If you can't, change permissions. If you can't, raise an error. Does file x/y exist? If not...
<Petruchio> I'd like to just declare what needs to be the case, and know that sensible steps are taken.
<leftylink> hmm... if there doesn't exist one, maybe install(1) can be looked into as an alternative
ramfjord has joined #ruby
<leftylink> because I sort of get the feeling that it does this thing
vondruch has quit [Read error: Connection reset by peer]
<Petruchio> That's an interesting idea.
rubydoc has quit [Excess Flood]
rubydoc has joined #ruby
moldorcoder7 has quit [Ping timeout: 246 seconds]
dionysus69 has joined #ruby
moldorcoder7 has joined #ruby
<adam12> I thought `un` had that functionality..
* adam12 goes to look
Swyper has quit [Remote host closed the connection]
bvdw has joined #ruby
blackmesa1 has joined #ruby
phaul has quit [Ping timeout: 256 seconds]
Swyper has joined #ruby
rubydoc has quit [Ping timeout: 260 seconds]
phaul has joined #ruby
rubydoc has joined #ruby
Swyper has quit [Remote host closed the connection]
akem has joined #ruby
dionysus69 has quit [Ping timeout: 264 seconds]
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
weaksauce has joined #ruby
dfucci has joined #ruby
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
aremaref has joined #ruby
bsdbandit-01 has joined #ruby
spideymang has joined #ruby
Swyper has joined #ruby
TomyWork has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
Rudd0 has quit [Ping timeout: 256 seconds]
banister_ has quit [Read error: Connection reset by peer]
leftylink has quit [Quit: Lost terminal]
leftylink has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
moldorcoder7 has quit [Quit: %bye mirc%]
moldorcoder7 has joined #ruby
BSaboia has joined #ruby
tubbo has quit [*.net *.split]
rubydoc has quit [Ping timeout: 240 seconds]
tubbo has joined #ruby
rubydoc has joined #ruby
royo25 has joined #ruby
rubydoc has quit [Excess Flood]
rubydoc has joined #ruby
spidey has joined #ruby
ur5us has joined #ruby
spideymang has quit [Ping timeout: 256 seconds]
royo25 has quit [Quit: Bye]
fuzzface has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
naftilos76_ has joined #ruby
<Petruchio> adam12: Had to go AFK, but I'll check it out, thanks.
naftilos76 has quit [Ping timeout: 240 seconds]
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
BSaboia has quit [Quit: Leaving]
bsdbandit-01 has joined #ruby
naftilos76_ has quit [Ping timeout: 256 seconds]
<adam12> Petruchio: Not sure if it solves your exact problem but maybe it can be paired with FileUtils.mkdir_p.
bsdbandit-01 has quit [Read error: Connection reset by peer]
phaul has quit [Ping timeout: 240 seconds]
rubydoc has quit [Ping timeout: 246 seconds]
phaul has joined #ruby
rubydoc has joined #ruby
dfucci has quit [Ping timeout: 268 seconds]
jinie has quit [Ping timeout: 256 seconds]
hiroaki has quit [Ping timeout: 265 seconds]
jinie has joined #ruby
gix has joined #ruby
fanta1 has quit [Remote host closed the connection]
qbklinm81 has joined #ruby
prion has quit [Ping timeout: 246 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
hiroaki has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
BananaDisco has joined #ruby
drincruz has joined #ruby
qbklinm81 has quit [Quit: Leaving.]
qbklinm81 has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
troll_ has joined #ruby
<troll_> hi !
<troll_> its a heavy burtation in ruby now.
baojg has joined #ruby
tempate has joined #ruby
<tempate> Is there a cleaner way of doing something like this: https://github.com/Tempate/Advent-of-Code-2020/blob/master/day16/main.rb#L109-L115 ?
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Excess Flood]
troll_ has left #ruby ["Leaving"]
<havenwood> tempate: I'd suggest a #find then !! it if you really need boolean values rather than truthy and falsey.
<adam12> or maybe Enumerable#any?
<adam12> or maybe build a range and ask for cover?
<havenwood> adam12: Oh, that's perfect. Yeah. And maybe a #between?
<havenwood> adam12: mmm. faster.
<tempate> I'm not sure what "building a range and asking for cover" means, tbh
<havenwood> &>> (3..5).cover?(42)
<adam12> tempate: range[:min]..range[:max].cover?(field)
<rubydoc> stderr: playpen: timeout triggered! (https://carc.in/#/r/a4fx)
<havenwood> tempate: That way it doesn't actually iterate through the range, but checks if it's within.
<havenwood> tempate: (Same as your logic, but faster.)
<nakilon> havenwood IIRC I use the #include? alias
<havenwood> nakilon: not an alias
<tempate> havenwood: hmmm, out of curiosity, why would it be faster?
<havenwood> tempate: it checks if the thing is below the min and above the max rather than looking at each element like #include?
<nakilon> maybe cover can accept other ranges, idk
<tempate> havenwood: isn't that what my logic does?
<tempate> havenwood: I agree it'd be more compact and readable, but faster?
<nakilon> I just feel like if I use .include? for arrays, why won't I use the same for range
<havenwood> tempate: Yeah, but yours uses multiple method calls. Calling methods is expensive, relatively.
<havenwood> tempate: Also, grammar parsing is about a third of Ruby execution time, so a smaller amount extra there.
<tempate> havenwood: range[:min] is a method call?
<havenwood> tempate: Yup!
<havenwood> tempate: range#[]
<tempate> Hmmm, interesting
<havenwood> tempate: Alternatively, you can: range.[](:min)
<havenwood> tempate: range[:min] is syntactic sugar for range.[](:min)
<tempate> havenwood: I see, I see
<havenwood> tempate: But it's the <= and => I'm talking about. Also syntactic sugar.
<havenwood> &>> 3.<=(5)
<rubydoc> # => true (https://carc.in/#/r/a4fy)
<havenwood> &>> 3 <= 5
<rubydoc> # => true (https://carc.in/#/r/a4fz)
<nakilon> is it because range is kind of a struct? I hear about this construction the first time
<tempate> havenwood: noted then
<tempate> havenwood: there's no black magic to remove the each business, right? As you can see I repeat it a few times in my code.
<havenwood> tempate: Most are probably #any? or #none? but I'm failing at multitasking here.
<havenwood> tempate: #each is fairly-seldom used, actually
<tempate> havenwood: in general or for this use-case?
<havenwood> nakilon: If you can #cover? it's generally better than #include?.
<nakilon> it covers more cases of different argument types, that is basically makes such methods slower
<havenwood> nakilon: #include? and #member? are aliases
<havenwood> nakilon: yup
spidey has quit [Remote host closed the connection]
<tempate> havenwood: I'm reading about all of this. It's beautiful!
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
bsdbandit-01 has joined #ruby
Swyper has quit [Remote host closed the connection]
<havenwood> tempate: i meant #any? and #none? for this use case but #each is generally much less used than say #map or predicate methods (ones ending in ?).
<havenwood> tempate: #each is what Enumerable is based on, it uses it internally to provide these other methods to Ranges, Arrays, Hashes, and all sorts of other collection classes that mix in Enumerable.
<tempate> havenwood: I've noticed that since I started writing ruby (only a couple of weeks ago), I'm leaning towards using map a lot more.
<tempate> havenwood: I see, I see
<havenwood> tempate: use of #each in your code is primary for side effects. there's usually a better Enumerable method when you're relying on a return value.
<havenwood> primarily*
<tempate> havenwood: what about https://github.com/Tempate/Advent-of-Code-2020/blob/master/day16/main.rb#L91-L97 . I'm returning two values so it's tricky
<havenwood> tempate: You can't actually return two values. That's not a thing in Ruby.
<havenwood> tempate: You can return an Array with two values in it.
chrisseaton has joined #ruby
<havenwood> tempate: Avoid explicit returns at the ends of methods in Ruby, since the last line will automatically be the return value.
<tempate> oh
bsdbandit-01 has quit [Read error: Connection reset by peer]
<tempate> havenwood: I didn't know that
<havenwood> tempate: [true, 0]
<havenwood> tempate: For that one, I think #find
<havenwood> tempate: something like:
<havenwood> tempate: valid_ticket = tickets.find { |ticket| ticket.is_field_valid(rules, field) }
<havenwood> tempate: valid_ticket ? [true, 0] : [false, valid_ticket]
<tempate> Hmmm, I see
stryek has quit [Quit: Connection closed for inactivity]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
<tempate> havenwood: but what would valid_ticket be exactly?
<havenwood> tempate: The ticket.
<havenwood> tickets = ['nope', 'not this', 'yup', 'dup', 'okay']; tickets.find { |ticket| ticket.include? 'yup' }
<tempate> havenwood: not sure how this'd work, tbh; valid_ticket would be the number of the ticket that didn't fulfill is_field_valid?
<havenwood> #=> "yup"
phaul has quit [Ping timeout: 246 seconds]
rubydoc has quit [Ping timeout: 268 seconds]
<havenwood> tempate: Stepping into a meeting but I'm sure others can help. :) The convention in Ruby is to name methods like #ticket_valid? rather than #is_ticket_valid.
phaul has joined #ruby
rubydoc has joined #ruby
blackmesa has joined #ruby
Rudd0 has joined #ruby
<tempate> havenwood: alright, thanks for everything
blackmesa1 has quit [Ping timeout: 260 seconds]
ruurd has joined #ruby
<leftylink> huh, seeing that code also causes me to ask a few questions
<leftylink> about the input
<leftylink> let me check
<tempate> Feel free to ask
<tempate> The input is inside that same folder, btw
<leftylink> huh. got lucky
<leftylink> no ticket has two invalid fields
<leftylink> that totally would have broken that code if any ticket did
<leftylink> too bad
<leftylink> I was thinking there would be a ticket with such
<tempate> hehe
<tempate> Yeah, I thought of that
<tempate> They were nice
<tempate> leftylink: if you don't mind me abusing of your kindness, what do you think of the code as a whole? Any advice?
<leftylink> oh, it's too bad you dont' have Ruby 2.7... if you did, then you'd be able to use filter_map instead of map.compact
<leftylink> there is sort of a missed opportunity in the input in that they could have made a field have three ranges, or one range, etc., but it's all two ranges, so I can't really complain
qbklinm81 has quit [Quit: Leaving.]
<tempate> I could install Ruby 2.7 if it's not too much of a hustle
somazero has quit [Remote host closed the connection]
<leftylink> .split(",").map(&:to_i) is done twice, is that enough to pull it out into a `ticket(str)` ? guess that depends on preference
prion has joined #ruby
<leftylink> oh... that calculate_ticket_scanning_error_rate is actually begging to use Enumerable#sum not #each
<tempate> Hmmm
<tempate> I didn't know #sum was a thing, tbh
<tempate> Is sum the same as map with inject(:+) ?
dionysus69 has joined #ruby
<leftylink> I suppose. though giving it a block is useful, since then it replaces map { ... }.reduce(:+)
<leftylink> replacing both the map and the reduce
<tempate> I see, I see
<tempate> Let me push my actual code
bsdbandit-01 has joined #ruby
<nakilon> hmmm, if I add bin/my_gem_binary to spec.files in gemspec, is it enough? how do I test that it works?
<tempate> leftylink: there, the code should be up to date. It has many, if not all, of the recommendations you and havenwood gave.
<nakilon> I've added the file there, also spec.bindir and spec.executable (still not sure if they are needed), then I did gem build my_gem, gem install my_gem-0.0.1.gem
<nakilon> "gem which" shows that the binary is there but it's somehow not in the PATH
bsdbandit-01 has quit [Read error: Connection reset by peer]
<nakilon> in case of the gem install from rubygems the "gem which" points to /Users/nakilon/.rbenv/shims/my_gem
<nakilon> but when installed from .gem it's /Users/nakilon/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/mygem-0.0.1
<nakilon> oh wait, that shim is "which my_gem", not "gem which my_gem"
blackmesa has quit [Ping timeout: 260 seconds]
<nakilon> looks like those shims are some magic sh scripts and "gem install my_gem.gem" don't create them so I'm unable to test if the executable is callable without pushing it to rubygems
<nakilon> not even with "rake install"
<nakilon> oh, nvm, I guess I actually forgot spec.bindir and spec.executable and they appeared to be important, after I've added them rebuilt and ran "rake install" it works now
cloud69 has quit [Quit: Connection closed for inactivity]
somazero has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
tty has joined #ruby
teclator has quit [Read error: Connection reset by peer]
tty is now known as cd
cd has quit [Client Quit]
cd has joined #ruby
bsdbandit-01 has joined #ruby
dionysus69 has quit [Ping timeout: 272 seconds]
fuzzface has quit [Quit: Leaving]
Technodrome has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
prion has quit [Ping timeout: 256 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
factormystic has quit [Read error: Connection reset by peer]
factormystic has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
prion has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Excess Flood]
orbyt_ has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
somazero has quit [Quit: Leaving]
BananaDisco has quit [Quit: Leaving]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
braincrash has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
michael__ has joined #ruby
michael__ has quit [Client Quit]