havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.1, 2.6.6, 2.5.8: 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!
mossplix has quit [Ping timeout: 246 seconds]
Eiam has quit [Remote host closed the connection]
lazarus1 has quit [Ping timeout: 240 seconds]
postmodern has joined #ruby
Eiam has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
factormystic has quit [Read error: Connection reset by peer]
Rudd0 has quit [Ping timeout: 246 seconds]
gix has quit [Ping timeout: 240 seconds]
Eiam has quit [Read error: Connection reset by peer]
oddp has quit [Ping timeout: 265 seconds]
ur5us has joined #ruby
BSaboia has joined #ruby
Rudd0 has joined #ruby
ghanima has joined #ruby
wymillerlinux has joined #ruby
ghanima has quit [Read error: Connection reset by peer]
ghanima has joined #ruby
wymillerlinux has quit [Quit: wymillerlinux]
BSaboia has quit [Quit: This computer has gone to sleep]
ChmEarl has quit [Quit: Leaving]
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
drincruz has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
BSaboia has joined #ruby
ur5us has joined #ruby
imode has quit [Ping timeout: 240 seconds]
justache has quit [Quit: The Lounge - https://thelounge.chat]
justache has joined #ruby
drincruz has quit [Ping timeout: 256 seconds]
imode has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
iNs has quit [Remote host closed the connection]
iNs has joined #ruby
postmodern has quit [Quit: Leaving]
mossplix has joined #ruby
mossplix has quit [Ping timeout: 272 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
plutes has quit [Ping timeout: 272 seconds]
alfiemax has joined #ruby
alfiemax has quit [Client Quit]
plutes has joined #ruby
justache has quit [Quit: The Lounge - https://thelounge.chat]
justache has joined #ruby
tau has quit [Ping timeout: 246 seconds]
mydog2 has quit [Ping timeout: 256 seconds]
mydog2 has joined #ruby
mheld has quit [Quit: Connection closed for inactivity]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 240 seconds]
memcorrupt has joined #ruby
memcorrupt has quit [Changing host]
memcorrupt has joined #ruby
memcorrupt has quit [Client Quit]
Garb0__ has joined #ruby
Lyubo1 has joined #ruby
spuk has joined #ruby
Garb0_ has quit [Ping timeout: 264 seconds]
rafadc has quit [Read error: Connection reset by peer]
rafadc has joined #ruby
spuk has quit [Quit: Human beings were created by water to transport it uphill.]
uplime has joined #ruby
<uplime> Is there a way in IRB to override/extend the top-level method_missing? I'm messing around with some non-serious things, and would like to perform an action if it ends up not being found
<havenwood> uplime: class << self
<leftylink> that reminds me...
<leftylink> yeah so I pasted http://sprunge.us/4BG5Hq in irb because someone asked whether it's possible to make a shell in ruby
<uplime> leftylink: haha thats kind of what im working on
<uplime> (just for personal use though)
<leftylink> so now you can just type ls it's as if you did ls in your shell
<uplime> havenwood: awesome, that looks to do it, thanks
<leftylink> but it couldn't handle stuff like . or /
<leftylink> so that sux
<havenwood> uplime: you're welcome
<uplime> I'm tempted to build the wrapper around pry, but it already has names for some commonly used commands
<havenwood> uplime: you can remove pry commands if you'd like
<uplime> oh really?
<uplime> is it just overshadowing them?
<havenwood> uplime: Pry.commands.rename_command '%cat', 'cat'
<havenwood> uplime: Pry.commands.rename_command '%ls', 'ls'
<uplime> ah, neat
<uplime> is it to, from?
<uplime> does pry just catch the % in that case?
mossplix has joined #ruby
Mikaela has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mossplix has quit [Ping timeout: 256 seconds]
<havenwood> uplime: The % is just the default command prefix.
<havenwood> uplime: Pry.config.command_prefix = '%'
<uplime> ah, i see
<uplime> thanks havenwood, this helps a lot
<havenwood> uplime: you're welcome
ivan` has joined #ruby
ivan` has quit [Client Quit]
BrianWGray has quit [Ping timeout: 265 seconds]
bocaneri has joined #ruby
sarna has joined #ruby
mossplix has joined #ruby
vondruch has joined #ruby
Garb0__ has quit [Quit: I'm out.]
rhe has joined #ruby
Roelof89 has joined #ruby
<Roelof89> good morning all
<havenwood> Roelof89: good eternal day!
schne1der has joined #ruby
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
<Roelof89> havenwood I changed my code to what you and some other people ask . is this better : https://gist.github.com/RoelofWobben/908289f389c0622858d75343c9779a4b
<havenwood> Roelof89: My feedback would be that since @x and @y can't be modified, they only need to be calculated once.
<havenwood> Roelof89: I mean, the distance and score only need to be calculated once.
<Roelof89> that is correct
<Roelof89> so I do not need the initialize ?
<havenwood> Roelof89: So I'd go the other direction, and store @distance and @score with attr_readers for those.
<havenwood> Roelof89: This design would make sense if @x and @y could be modified.
<Roelof89> hmm, now I have to think how to do that. Yesterday someone said I need to make a function for distance and not doing it in the initialize
<sarna> what's the terminology when it comes to something implementing a module? would I say something "implements Enumerable", "mixes in Enumerable" or something else?
<havenwood> sarna: Yeah, mixes in.
<sarna> havenwood: thanks :)
<Roelof89> havenwood and attrr is not explained in rubymonk as far as I did right now
<havenwood> Roelof89: What's the requirement here? Is there a certain interface you're aiming for?
Bounga has joined #ruby
<havenwood> Roelof89: I don't see any inherent reason to have a class. If there's no internal state to track, a simple module is better.
<havenwood> Roelof89: If you're aiming for something you initialize that has a #score method, just for fun, memoize the @score.
<havenwood> Roelof89: Say more about why you're doing this, and I'd be happy to recommend what to do.
<Roelof89> I try to solve a exercism challenge and that one is asking for a class , a initialize and a score function
<Roelof89> The challenge is about finding out a score on a dartboard depending on what the distance of the dart
cgfbee has quit [Ping timeout: 260 seconds]
<Roelof89> what in the score and initialize function is up to me , the only thing I noticed is that initialize needs two arguments
<Roelof89> See the text I also pasted in the gists , that is also all I know
<havenwood> Roelof89: You'd need to know how you're using it to decide how to design it optimally. If a dart's @x and @y are known at creation and don't change and the score is only checked once, no need to ever even initialize and just use a module function. If they don't change but are checked repeatedly, memoize the value on initialization.
<havenwood> Roelof89: This design isn't as nice as when you last visited though.
<havenwood> Roelof89: The glaring issue here is that #distance can get called three times for a single #score.
<havenwood> Roelof89: I think that's a regression.
<havenwood> Roelof89: Line 14 calls #distance, does the calculation, then if it's greater than 1, #distance is called again on lie 16, and so on.
<havenwood> Roelof89: If @x and @y are changing, this is chaos. If they're not changing, even recalculating @score is unnecessary.
<Roelof89> hmm, you are right
<Roelof89> maybe make a variable that calculates the distance in the score function and use that for finding out the score
<havenwood> Roelof89: If the score doesn't change, don't recalculate it at all.
<havenwood> Roelof89: @score = calculate_it_just_once()
<havenwood> Roelof89: attr_reader :score
<Roelof89> moment, is @score for you the score of the darts
<havenwood> Roelof89: What the #score method currently returns. Just calculate it on initialize and return that instance variable if someone wants the score.
<havenwood> Roelof89: If the score doesn't change after initialization, never calculate it ever again after initialization.
<havenwood> Just return the stored @score.
<Roelof89> I need the score function otherwise the test are failing
<havenwood> Roelof89: No, I don't meann that.
<Roelof89> :'(
<havenwood> Roelof89: Try getting rid of the `def score` entirely. Move that stuff to initialize.
<Roelof89> I cannot, the tests of this challenge wants a score function
<Roelof89> see the tests I added to the gists
<havenwood> Roelof89: The score method is provided by line 3.
<havenwood> Roelof89: You can!
<havenwood> Roelof89: Try it...
<leftylink> WHAT
<leftylink> why is there BOTH an attr_reader :score and a `def score`
<havenwood> ^
<Roelof89> he, it working
<Roelof89> I think I need to read more about the attr*. and what they are doing exactly
<havenwood> Roelof89: def score; @score; end
<havenwood> Roelof89: attr_reader :score
<havenwood> Roelof89: Those ^ are the same.
<Roelof89> oke
<havenwood> Roelof89: Don't set: @x = x
<havenwood> Roelof89: Just assign @score once.
<Roelof89> so attr_reader score makes a function so I can return the score without making a seperate function for it
<havenwood> Roelof89: A method.
<havenwood> Roelof89: A function doesn't know about or rely on state.
<havenwood> Roelof89: @score = case
<havenwood> Roelof89: You only need `@score =` on that one line.
<havenwood> Roelof89: No @x or @y.
<havenwood> Roelof89: You have x and y, and you don't need @x and @y.
<Roelof89> oke, updated the gists
<havenwood> Roelof89: That's a reasonable solution.
<Roelof89> oke
<Roelof89> I think the perfect solution does not exist
<al2o3-cr> &>> class Darts def initialize(x,y) @z = (x.abs2 + y.abs2) ** 0.5 end; def score; @z <= 1 ? 10 : @z <= 5 ? 5 : @z <= 10 ? 1 : 0 end end; Darts.new(0,0).score # bullseye, i win! :P
<rubydoc> # => 10 (https://carc.in/#/r/9biq)
<sarna> how do you order methods in a class? is it initialize -> needed for mixed in modules -> others? or something else?
<al2o3-cr> where the trophy at?
<Roelof89> al2o3-cr and why do you win then ?
<al2o3-cr> i got bullseye
<Roelof89> :)
mr_rich101 has quit [Ping timeout: 260 seconds]
mr_rich101 has joined #ruby
<havenwood> sarna: The order is only by convention, if that.
<havenwood> sarna: Typically, initialize is up top.
<sarna> havenwood: yeah, I'm asking if there is any existing convention :)
<sarna> I only know about initialize
<havenwood> sarna: No particular method is needed for mixing in a module, but some may require a method be defined.
<havenwood> sarna: For example, Comparable presumes #<=> and Enumerable presumes #each.
<sarna> havenwood: I'm mixing in Enumerable at the moment, I was wondering where I should put #each
kmplsv has left #ruby ["WeeChat 2.8"]
<sarna> I'm probably overthinking this
chalkmonster has quit [Quit: WeeChat 2.8]
<havenwood> sarna: Module mixins are typically done up top. Methods after. Otherwise, we just pick what looks pretty.
<havenwood> sarna: Yeah, it's just aesthetic.
<sarna> havenwood: yep, I was gonna put #each right after initialize, but then I started thinking :D shouldn't have
<havenwood> haha
<al2o3-cr> i must violate 90% of the style guide haha
<havenwood> al2o3-cr: one method to rule them all
<sarna> how would you test #each, by the way? make `.each do |foo|` and then check.. well, what?
<al2o3-cr> havenwood: yup :P
<havenwood> sarna: what does it yield?
dviola has quit [Quit: WeeChat 2.8]
cgfbee has joined #ruby
<Roelof89> pfff, next challenge is not nice. It looks I need a regex to split a string on several things and I hate regex :(
<havenwood> sarna: I'd say test that #each without a block yields an Enumerator, and that it's a working one. Then that #each with a block is as expected. Fair to do the latter with #map or whatever, since Enumerable is presumed working.
<havenwood> Roelof89: Minigame.
<Roelof89> ??
<havenwood> Roelof89: Regexp is a mini-game embedded within the language.
<havenwood> Like pinball in a space oddesy.
<leftylink> there's https://regexcrossword.com/ but that's for understanding regexes, rather than creating them
<leftylink> I know executeprogram has a regex course though I'm not familiar with what their pricing is
<Roelof89> oke, but still I do not like them. I think I need to make a regex so I can abbreviate them
<sarna> havenwood: sorry, I'm a bit confused. I should check if Foo#each returns an Enumerator, then that the Enumerator returned works (how to check that?), and then that Foo#each with a block works as expected?
<sarna> and do you mean to check that block case with #map instead?
<havenwood> sarna: yeah, I'm very tired so take it with a grain of salt but that's what i meant
xco has joined #ruby
<sarna> havenwood: no worries, thanks for helping me out :)
<Roelof89> havenwood is it then almost bed time or slept not good ?
<sarna> I'm new to TDD and all that stuff
<Roelof89> sarna that makes 2 of us, But I think you are further then me. I still have to learn to make tests
<havenwood> Roelof89: i'll keep intermittently trying to sleep. one of these times it'll take.
<havenwood> rescue NoSleepError; retry
<sarna> Roelof89: it's a journey :D
chalkmonster has joined #ruby
<havenwood> g'night!
<sarna> sleep well o/
<al2o3-cr> o/
* Roelof89 is going to think the rest of the day how to do this work : https://gist.github.com/RoelofWobben/6d9347de8fcf6a6899de7783d2c511b2
<Roelof89> I could use split with a regex or direct a regex to take the parts I need
infernix has joined #ruby
<Roelof89> testing is not the problem but how to make the right code to output the abbrevations
<al2o3-cr> Roelof89: _hint_ use word boundries \b
<Roelof89> oke, then I have to find a site where I can test things
<al2o3-cr> Roelof89: rubular.com
<al2o3-cr> or test in irb/pry
bocaneri has quit [Ping timeout: 240 seconds]
bocaneri has joined #ruby
exmortus has joined #ruby
<Roelof89> im not totally happy ` string.split(/\b/) ` gives me ` ["Portable", " ", "Network", " ", "Graphics"] ` so I get empty entries in my array
<al2o3-cr> Roelof89: you need more than just \b also use #scan instead of #split.
rippa has joined #ruby
mr_rich101 has quit [Ping timeout: 258 seconds]
jidar has quit [Ping timeout: 258 seconds]
<Roelof89> oke, after some googling I found this : ` /\b[a-zA-Z]/ ` . Is it correct that i takes the boundries and take the first character if its in the range a-z or A-Z ?
<al2o3-cr> Roelof89: basically, yup.
jidar has joined #ruby
<Roelof89> then another challenge solved and learned something
<al2o3-cr> Roelof89: module Acronym module_function def abbreviate(s) s.scan(/\b\p{L}/).join.upcase end end
<al2o3-cr> that was my attempt
<Roelof89> this is my attempt : `string.scan(/\b[a-zA-Z]/).join.upcase `
<al2o3-cr> in case they include unicode characters.
<Roelof89> still a lot to learn but that is oke
<Roelof89> ruby is still very powerfull
<al2o3-cr> Roelof89: sure, everyday is a learning day! :P
imode has quit [Ping timeout: 240 seconds]
<Roelof89> yep, and not only for learning developing software :)
<al2o3-cr> :)
<Roelof89> also for learning how to deal with if things are not going as you want or learn how to deal with corana :(
<Roelof89> as a example
<Roelof89> now wait till mentor feedback
mossplix has quit [Remote host closed the connection]
oddp has joined #ruby
mossplix has joined #ruby
bmo has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
* al2o3-cr kernel bump 5.7.5 time to reboot.
al2o3-cr has quit [Quit: WeeChat 2.8]
al2o3-cr has joined #ruby
alexherbo2 has joined #ruby
arahael1 is now known as Arahael
akem has quit [Ping timeout: 260 seconds]
romanlevin33 has quit [Quit: The Lounge - https://thelounge.chat]
romanlevin33 has joined #ruby
cd has joined #ruby
Roelof89 has quit [Ping timeout: 245 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lazarus1 has joined #ruby
lazarus1 has left #ruby [#ruby]
bmo has quit [Quit: Textual IRC Client: www.textualapp.com]
mr_rich101 has joined #ruby
BrianWGray has joined #ruby
roelof5 has joined #ruby
<roelof5> Is there somewhere a tutorial or course where I can learn to make my own test in minitest ?
xco has joined #ruby
BrianWGray has quit [Remote host closed the connection]
BrianWGray has joined #ruby
BH23 has quit [Quit: Leaving]
BH23 has joined #ruby
newalexandria[m] has joined #ruby
vondruch has quit [Ping timeout: 264 seconds]
<jhass> uh, how about minitest's docs?
bsdbandit-01 has joined #ruby
exmortus has quit [Read error: Connection reset by peer]
exmortus has joined #ruby
vondruch has joined #ruby
drincruz has joined #ruby
<roelof5> thanks
Emmanuel_ChanelW has joined #ruby
drincruz has quit [Ping timeout: 260 seconds]
Technodrome has joined #ruby
dualfade has quit [Ping timeout: 258 seconds]
drincruz has joined #ruby
dualfade has joined #ruby
AndreYuhai has joined #ruby
<AndreYuhai> I am using httprb and I want a persistent connection. But if I set headers like client.headers(headers).get('/') then the handshake is always done. What am I doing wrong?
burningserenity has joined #ruby
drincruz has quit [Ping timeout: 265 seconds]
Fischmiep has joined #ruby
burningserenity has quit [Remote host closed the connection]
drincruz has joined #ruby
stnly has quit [Quit: goodbye]
stnly has joined #ruby
Emmanuel_ChanelW has quit [Quit: Leaving]
roelof5 has quit [Ping timeout: 245 seconds]
Bounga has quit [Remote host closed the connection]
mr_rich101 has quit [Ping timeout: 264 seconds]
burningserenity has joined #ruby
Lyubo1 has quit [Ping timeout: 246 seconds]
Lyubo1 has joined #ruby
mr_rich101 has joined #ruby
leitz has joined #ruby
factormystic has joined #ruby
Bounga has joined #ruby
marahin has quit [Quit: ZNC 1.6.3+deb1ubuntu0.2 - http://znc.in]
reffle has joined #ruby
marahin has joined #ruby
marahin has quit [Changing host]
marahin has joined #ruby
cd has quit [Quit: cd]
arahael1 has joined #ruby
Arahael has quit [Ping timeout: 264 seconds]
<AndreYuhai> adam12, Thank youu! :)
stryek has joined #ruby
sarna has quit [Quit: Connection closed]
Hanma[m] has joined #ruby
mossplix has quit [Ping timeout: 246 seconds]
Nerium has joined #ruby
con3 has joined #ruby
akem has joined #ruby
s2013 has joined #ruby
alexherbo21 has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo21 is now known as alexherbo2
reffle has quit [Changing host]
reffle has joined #ruby
chris__ has joined #ruby
ChmEarl has joined #ruby
Nerium is now known as nerium
orbyt_ has joined #ruby
<leitz> The Perl Conference is being done with Zoom. Likely the only reason I get to go. Now we need a good Ruby conference.
RiPuk has quit [Quit: ZNC 1.8.1 - https://znc.in]
RiPuk has joined #ruby
TCZ has joined #ruby
cadeskywalker has joined #ruby
<adam12> leitz: Interested to see what RubyConf will look like this year. Will they go the same way as RailsConf? Time will tell.
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
<adam12> leitz: The BrightonRuby conf was interesting this year; they're physically mailing Why's book all around the world, as part of the "swag" for the conference.
bsdbandit-01 has quit [Ping timeout: 246 seconds]
BH23 has quit [Remote host closed the connection]
Eiam has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bsdbandit-01 has joined #ruby
RiPuk has quit [Quit: ZNC 1.8.1 - https://znc.in]
RiPuk has joined #ruby
BH23 has joined #ruby
<leitz> adam12, thanks for the reminder. I know the southeast Ruby conference had already planned to skip 2020 even before the covid stuff.
D9 has quit [Quit: Leaving]
<leitz> Signed up for updates on RubyConf. I'm trying to stay enthused about programming for work, and need more Ruby. :)
nerium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has joined #ruby
<leitz> Perl will be coming out with a Perl 7. Interesting.
Bounga has quit [Remote host closed the connection]
bsdbandit-01 has quit [Ping timeout: 265 seconds]
bsdbandit-01 has joined #ruby
<apotheon> err
<apotheon> Wouldn't Perl 7 just be Perl 6 v2?
<apotheon> . . . or has Perl 6 turned out to be such a turkey that they're working on a replacement for it?
<al2o3-cr> more like 5.32
<leitz> Perl 7 will be Perl 5.32 with "good coding stuff like use strict as default"
<leitz> There will be a Perl 5 compatibility mode, but no Raku compat, from the conversation I just saw.
gitter1234 has joined #ruby
con3 has quit [Quit: ZNC 1.7.5 - https://znc.in]
<apotheon> interesting
<leitz> IIUC, development on Perl 5 itself is difficult becuase they are very committed to backwards compatibility. Even to the point of re-introducing bugs. So the theory of Perl 7 is to allow that transition so new development could be easier.
TCZ has quit [Quit: Leaving]
_0x03b5 has joined #ruby
<apotheon> I see.
nerium has joined #ruby
smccarthy has joined #ruby
nerium has quit [Client Quit]
Bounga has joined #ruby
Bounga has quit [Ping timeout: 272 seconds]
_0x03b5 has quit [Remote host closed the connection]
nerium has joined #ruby
<smccarthy> Using bundler inline on AWS lambda gives me "Gem::FilePermissionError: You don't have write permissions for the /var/runtime directory". I see ENV[LAMBDA_RUNTIME_DIR] is set to /var/runtime , ENV[RUBYLIB] is /var/task:/var/runtime/lib:/opt/ruby/lib .
<smccarthy> I already updated BUNDLE_PATH=/tmp , BUNDLE_IGNORE_CONFIG=true , BUNDLE_USER_HOME=/tmp , BUNDLE_PATH__SYSTEM=false
nerium has quit [Quit: Textual IRC Client: www.textualapp.com]
nerium has joined #ruby
Roelof54 has joined #ruby
<Roelof54> What do you experts think of this solution : https://gist.github.com/RoelofWobben/fe9497e2f78370992a0ffbe97aa7163f/edit . I have to convert seconds to a sort of time object
<havenwood> Roelof54: Nothing there.
<Roelof54> already awake @havenwood
<havenwood> Roelof54: I need a few more days of trying to sleep.
<Roelof54> you may borrow it from me. I can sleep the whole day
<havenwood> Roelof54: Consider Integer#divmod.
<havenwood> &>> 42.divmod(4)
<rubydoc> # => [10, 2] (https://carc.in/#/r/9bkm)
<havenwood> Roelof54: div, mod = 42.divmod(4)
<Roelof54> oke, where div is the hours and mod the minutes I think
<havenwood> Roelof54: Consider refactoring by extracting a private function for line 15.
<havenwood> Roelof54: Yes.
<havenwood> Roelof54: def format_time(minutes:, hours:)
<havenwood> Roelof54: You're missing an `end` in the gist but maybe a copy omission.
<Roelof54> hmm, divmod is not working as I expect : ` (hours, minutes) = @seconds divmod (60)`
<leftylink> divmod is not an infix
<Roelof54> ` syntax error, unexpected tIDENTIFIER, expecting end (SyntaxError)...urs, minutes) = @seconds divmod (60) `
arahael2 has joined #ruby
<leftylink> also I find it important to point out that since hours and minutes are misnamed.
<leftylink> if I input 5 into a microwave, I get 5 seconds, not 5 minutes. seconds don't magically turn into minutes.
arahael1 has quit [Ping timeout: 264 seconds]
<Roelof54> Still the same annoying error : ` (hours, minutes) = @seconds.divmod (60) `
<Roelof54> got it working
c59 has joined #ruby
<Roelof54> leftylink you are right , I will change it
<Roelof54> and I think I have to find another way to display a number as 02 then that I use
<Roelof54> I see that I use two times `to_s.rjust ` to both minutes and seconds
<Roelof54> or can I do that with the private function you were talking about havenwood
<havenwood> Roelof54: Try extracting a method, then show us. :)
<havenwood> Roelof54: Just put a `private` on a line below, then define your helper function.
<havenwood> Roelof54: Try it different ways.
<havenwood> Roelof54: Often it helps to look at a potential refactor
<havenwood> Roelof54: Keep iterating
livcd_ has quit [Ping timeout: 265 seconds]
<Roelof54> new version in the same gists link
r29v has joined #ruby
<Roelof54> I hope its now good enough
<havenwood> Roelof54: Style issue:
<havenwood> minutes, seconds = @seconds.divmod(60)
<Roelof54> changed
<havenwood> Roelof54: Now move it outside the if statement.
<havenwood> Roelof54: minutes, seconds = if ...
<havenwood> DRY
<Roelof54> updated
<havenwood> Roelof54: Now just whitespace issues. You could consider more extract method refactors.
<havenwood> Roelof54: Outside of Rails, folk tend to not leave that newline inside of a Class.
<havenwood> Roelof54: Extra spaces onn line 8, 13, 16, etc.
<havenwood> Roelof54: Rubocop might be nice at this point.
<havenwood> Roelof54: rubocop -a MicroWave.rb
<havenwood> Roelof54: Use snake_case for filenames.
<havenwood> Roelof54: microwave.rb
<havenwood> Roelof54: Match the filename to the class name.
<havenwood> Roelof54: MicroWave becomes micro_wave.rb or Microwave becomes microwave.rb.
<smccarthy> I even see "Bundler will use `/tmp/bundler20200624-9-1kz4qm99' as your home directory temporarily." if that matters. I just dont know why its trying to write to /var/runtime
<Roelof54> the name of the class and function are given
<havenwood> Roelof54: I'm complaining about your gist filename.
<havenwood> :
<havenwood> smccarthy: I can't think of a reason it would.
<smccarthy> havenwood: I tried looking at the stacktrace and I think its getting /var/runtime as the current directory, but I am doing "Dir.chdir "/tmp" do" and the bundler inline code is in that loop, so not really sure.
<al2o3-cr> Roelof54: consider using format/sprintf too.
<havenwood> smccarthy: Do you need to set LAMBDA_TASK_ROOT or somethingn?
<havenwood> Hrm.
Eiam has quit [Read error: Connection reset by peer]
<smccarthy> oh maybe ? I can try LAMBDA_TASK_ROOT and LAMBDA_RUNTIME_DIR , to at least see if it affects the error
<al2o3-cr> &>> format('%02d:%02d', *90.divmod(60))
<rubydoc> # => "01:30" (https://carc.in/#/r/9bkr)
<smccarthy> nope, didnt affect it
<Roelof54> al2o3-cr oke, I have to google how that works
<al2o3-cr> Roelof54: don't google read the docs.
<Roelof54> o, you gave a example
<al2o3-cr> &ri format Roelof54
<rubydoc> al2o3-cr: I found 5 entries matching method format. Use &list format if you would like to see a list
<al2o3-cr> &ri sprintf Roelof54
<smccarthy> havenwood: I wonder if this is the reason for my failure : `Notice that chdir only works within your Ruby process, it doesn’t affect the “outside world”. It won’t change your shell’s working directory after your Ruby program stops running.` from https://www.rubyguides.com/2020/02/ruby-dir/
<smccarthy> but that shouldn't affect me
arahael2 has quit [Ping timeout: 260 seconds]
<Roelof54> I like that too
Eiam has joined #ruby
chris__ has quit [Remote host closed the connection]
c59 has quit [Remote host closed the connection]
<al2o3-cr> Roelof54: format('%02d:%02d', *@seconds.divmod(@seconds < 100 ? 60 : 100))
<Roelof54> oke, I do not know if I find that more readable but I get the point
arahael2 has joined #ruby
<al2o3-cr> Roelof54: but sure, that way works also.
<Roelof54> I see it, it is in a way cleaner that I do not need some temp variables , that is a good point
<Roelof54> but its also a lot in one go
<Roelof54> maybe I have to get use to the ternary operator
<al2o3-cr> Roelof54: i can take a bit of getting used to if you've never used it before, especially nested.
howdoi has joined #ruby
<al2o3-cr> Roelof54: i try to write simple, clean, concise code without too much trickery, but that doesn't happen sometimes.
<Roelof54> that is also what I wanted to learn , Write clean code which is clear what it does
<Roelof54> is there a plugin in vscode that can help me with writing that and with formattting the code to the ruby standard
<al2o3-cr> Roelof54: for formatting code you can follow this https://github.com/rubocop-hq/ruby-style-guide for vscode, never used it.
<havenwood> Roelof54: gem install rubocop
<havenwood> Roelof54: VSCode just works with it, iir.
<al2o3-cr> Roelof54: rubocop comes with an auto-correct feature.
* al2o3-cr should use rubocop more often
<Roelof54> oops. a lot of complains :'(
<Roelof54> oops, rubocop does not like the %s in the format : ` Style/FormatStringToken: Prefer annotated tokens (like %<foo>s) over unannotated tokens (like %s). format('%02d:%02d', *@seconds.divmod(@seconds < 100 ? 60 : 100)) `
<al2o3-cr> it moans more than a woman
<Roelof54> so ignore it , just like this one : ` Style/Documentation: Missing top-level class documentation comment.class Microwave `
bocaneri has quit [Remote host closed the connection]
cnsvc has joined #ruby
<al2o3-cr> Roelof54: you can.
c59 has joined #ruby
<Roelof54> oke, then I will commit this one and see what a exercism mentor finds of it
<Roelof54> Both thanks
dfucci has quit [Ping timeout: 260 seconds]
dfucci has joined #ruby
orbyt_ has joined #ruby
<al2o3-cr> <> formatting {} no formatting always become unstuck with that one.
imode has joined #ruby
<Roelof54> for time spend some time with the family and then try to get some sleep in a very warm house, Today in the Netherlands 30 degrees, not normal
c59 has quit [Remote host closed the connection]
<al2o3-cr> 28 degrees here and melting lol
c59 has joined #ruby
<Roelof54> I know the feeling. Where do you live ?
<al2o3-cr> UK
<Roelof54> here till Saturday temperatures of 30 degrees , and then rain and thunder , Always the same story
<al2o3-cr> Roelof54: pretty much the same.
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
bsdbandit-01 has joined #ruby
<Roelof54> I could not resist so I did another exercism challenge : ` ('a'..'z').all? { |character| text.downcase.include? character } `
<Roelof54> what do you experts think of this line to check if a word is a pangram
leitz has quit [Quit: Leaving]
<jhass> not too bad, could move the .downcase out of the loop :)
<leftylink> if one of the teaching points of the pangram is to teach about performance, then surely there will be comments on that. but since I don't know whether that's included in the teaching points of that exercise, I will refrain for now
bsdbandit-01 has quit [Ping timeout: 260 seconds]
<Roelof54> they do not mentioned what the learning points are but im sure performance is not one of them
<leftylink> very well then.
<Roelof54> exercism is as I see it more about learning and practising with things like OOP or arrays or loops so concepts
Roelof54 has quit [Remote host closed the connection]
<skx86> thats not a loop
roelof3 has joined #ruby
bsdbandit-01 has joined #ruby
<roelof3> stupid channel, the connection was lost :'(
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
<roelof3> @jhass so you would do `text_downcase = text.downcase and use text_downcase in the all method ?
<havenwood> roelof3: Check the logs if you miss anything: https://irclog.whitequark.org/ruby
<jhass> roelof3: yeah
<roelof3> I did and miss nothing
<roelof3> no more feedback ?
<jhass> nah, it's simple enough :D
gr33n7007h has joined #ruby
smccarthy has quit [Remote host closed the connection]
c59 has quit [Remote host closed the connection]
chris__ has joined #ruby
al2o3-cr has quit [Ping timeout: 256 seconds]
gr33n7007h is now known as al2o3-cr
chris__ has quit [Ping timeout: 258 seconds]
roelof3 is now known as RoelofWobben
r29v has quit [Quit: r29v]
<RoelofWobben> GN all :sleepy
<al2o3-cr> o/
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
bsdbandit-01 has joined #ruby
titanbiscuit has quit [Ping timeout: 265 seconds]
titanbiscuit has joined #ruby
chris__ has joined #ruby
RoelofWobben has quit [Remote host closed the connection]
chris__ has quit [Ping timeout: 240 seconds]
dviola has joined #ruby
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
burningserenity has quit [Quit: Leaving.]
xco has quit [Quit: Textual IRC Client: www.textualapp.com]
bmurt has joined #ruby
vondruch has quit [Ping timeout: 264 seconds]
KramerC has quit [Ping timeout: 260 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
gix has joined #ruby
CalimeroTeknik has quit [Ping timeout: 265 seconds]
CalimeroTeknik_ has joined #ruby
tekk has joined #ruby
chris__ has joined #ruby
Mikaela has quit [Remote host closed the connection]
Roelof59 has joined #ruby
<Roelof59> Are there other ways to learn ruby . I did the codeacademy and some parts ofrubymonk but I see I do not know enough to write clean code
CalimeroTeknik_ is now known as CalimeroTeknik
<havenwood> Roelof59: Write more code and get code reviews. You'll learn.
bsdband12 has joined #ruby
<Roelof59> oke, so go on with what I do now. Write solutions to exercism and ask here for review
<CalimeroTeknik> the fundamentals of programming also help
<CalimeroTeknik> PAC learning has its limits
bsdbandit-01 has quit [Ping timeout: 260 seconds]
<Roelof59> PAC learning ?
<CalimeroTeknik> for short, a technique that works for some problems, but does not include problems where you can't tell if you're close to a solution and actually have to exactly find it to tell you did
<CalimeroTeknik> whenever you learn by examples or by experience, you're doing some form of PAC learning
<CalimeroTeknik> for a ridiculous example of applying PAC learning to a case where it isn't very efficient: https://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
<CalimeroTeknik> oops, isn't ruby
impermanence has joined #ruby
<Roelof59> but it makes the point. He/she does totally not what is asked. I think fizzbuzz can be written in ruby in some 5 - 10 lines ?
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<CalimeroTeknik> it depends a bit on the paradigm you use and the clarity attained (not counting comments, which are for saying "why", not "what")
r29v has joined #ruby
<Roelof59> was just a wild guess but now really time to sleep. Daugther needs to school tomorrow morning at 8 o clock :'(
<CalimeroTeknik> parent and programmer, both are high-subtlety activities
<Roelof59> programmer is a hobby , parent is my job
<Roelof59> GN all
ur5us has joined #ruby
<rapha> y'all
<rapha> with Sequel
<rapha> if .save comes back true on a .new row, but then the database (SQLite) in the end doesn't have the new item, what could be going wrong there?
kinduff has joined #ruby
schne1der has quit [Ping timeout: 240 seconds]
Roelof59 has quit [Remote host closed the connection]
gitter1234 has quit [Quit: Connection closed for inactivity]
<rapha> (debugging info shows the insert statement, a select statement afterwards, and even the commit statement)
TCZ has joined #ruby
r29v has quit [Ping timeout: 240 seconds]
xco has joined #ruby
<adam12> rapha: Maybe better asked in #sequel, but can you paste the SQL log somewhere? and maybe any relevant code?
<adam12> rapha: I can only think of 2 things off the top of my head; different db connection strings (file, in-memory, or both), or a transaction that's rolled back elsewhere. Hard to say without seeing logs and code tho.
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
orbyt_ has joined #ruby
wymillerlinux has joined #ruby
gitter1234 has joined #ruby
wymillerlinux has quit [Quit: wymillerlinux]
wymillerlinux has joined #ruby
gitter1234 has quit [Client Quit]
nychtel has joined #ruby
nychtel has quit [Client Quit]
nychtel_ has joined #ruby
reffle has quit [Quit: Leaving]
Tempesta has quit [Quit: See ya!]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
chris__ has quit [Ping timeout: 256 seconds]
coniptor has quit [Ping timeout: 265 seconds]
coniptor has joined #ruby
TCZ has quit [Quit: Leaving]
Tempesta has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nerium has quit [Quit: Textual IRC Client: www.textualapp.com]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<rapha> adam12: it magically started working after i put the snippet of code from an .rb file into a Rakefile. don't ask me why or how.
<havenwood> rapha: How and why?
<havenwood> :P
stryek has quit [Quit: Connection closed for inactivity]
<al2o3-cr> havenwood: i know this might sound like a weird question but, the async gem, in the source code they use 2 space indentation but for example readme.me they use tabs? formatting issue or something
<havenwood> al2o3-cr: Yeah, ioquatix has an unfortunate historical preference for hard tabs. Folk have been coaxing towards spaces and he's been receptive but it's a work in progress. :P
<al2o3-cr> oh, that explains it :) that has been puzzling me for ages :P cheers!
drincruz has quit [Ping timeout: 264 seconds]
wymillerlinux has quit [Ping timeout: 258 seconds]