baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: 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!
thy0 has joined #ruby
oncall-pokemon has quit [Quit: Connection closed for inactivity]
Creatornator has joined #ruby
za1b1tsu has quit [Ping timeout: 272 seconds]
DarthGandalf has quit [Ping timeout: 240 seconds]
Caerus has joined #ruby
Caerus has quit [Client Quit]
cagomez has quit [Remote host closed the connection]
tty has quit [Read error: Connection reset by peer]
sameerynho has quit [Ping timeout: 244 seconds]
Caerus has joined #ruby
cthu| has joined #ruby
cthulchu_ has quit [Ping timeout: 255 seconds]
zerowaitstate has quit [Ping timeout: 256 seconds]
y3n has quit [Ping timeout: 256 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
herbmillerjr has joined #ruby
DarthGandalf has joined #ruby
vonfry has joined #ruby
cthu| has quit [Ping timeout: 240 seconds]
arekushi has joined #ruby
patr0clus has quit [Ping timeout: 240 seconds]
<havenwood> #=> "e"
Creatornator has joined #ruby
<Caerus> .
arescorpio has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 240 seconds]
bmurt has joined #ruby
clemens3 has quit [Ping timeout: 248 seconds]
AJA4350 has quit [Remote host closed the connection]
duderonomy has quit [Ping timeout: 256 seconds]
duderonomy has joined #ruby
sauvin has joined #ruby
scientes has joined #ruby
<scientes> how would i convert 76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586 into 0xff, 0xff, 0xff ?
<Zarthus> as a string or a hex
<Zarthus> (int)
<scientes> string, i've got it, i was just lazy
<Zarthus> because it's already hexadecimal you could .split(/../).map { |v| '0x'+v }
<scientes> .split(/../) thats what i was looking for
<scientes> doesn't work
<scientes> the split(/../)
<havenwood> scientes: '76b8e0ada0'.scan(/../) #=> ["76", "b8", "e0", "ad", "a0"]
sylario has quit [Quit: Connection closed for inactivity]
tty has joined #ruby
kapil___ has joined #ruby
arescorpio has quit [Quit: Leaving.]
Emmanuel_Chanel has joined #ruby
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
vonfry has quit [Quit: WeeChat 2.2]
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
mroutis has joined #ruby
gix has quit [Disconnected by services]
samort7 has joined #ruby
<samort7> How would I put a colon in a symbol? Is there a way to escape it, say, when making a hash?
<samort7> Like, this is invalid: attributes = { api:id: 'SKU',
<samort7> api:name: 'Item_Name' }
<mroutis> samort7, try something like :'api:name'
<havenwood> samort7: 'api:name': 'samort7'
<mroutis> >>puts :'api:name'
<ruby[bot]> mroutis: # => api:name ...check link for more (https://eval.in/1046641)
<samort7> ah, ok. Thanks!
<mroutis> >>puts { 'api:name': 'samort7' }
<ruby[bot]> mroutis: # => /tmp/execpad-3743ed528847/source-3743ed528847:2: syntax error, unexpected ':', expecting '}' ...check link for more (https://eval.in/1046642)
<mroutis> oops
<havenwood> samort7: {'api:name': 'samort7'} #=> {:"api:name"=>"samort7"}
<havenwood> samort7: :"api:name".class #=> Symbol
<samort7> Ah neat. Why did mroutis' fail?
<mroutis> puts was trippin' with the hash
<mroutis> >> puts { a: 1 }
<ruby[bot]> mroutis: # => /tmp/execpad-dd7d5d519cfe/source-dd7d5d519cfe:2: syntax error, unexpected ':', expecting '}' ...check link for more (https://eval.in/1046643)
<samort7> oh. It doesn't like that I guess
<samort7> >> outer_hash = { x: [] }; inner_hash = { dog: 'bark'}; outer_hash['x'].push(inner_hash); puts outer_hash;
<ruby[bot]> samort7: # => undefined method `push' for nil:NilClass ...check link for more (https://eval.in/1046644)
<samort7> hmmm
<mroutis> what are you trying to achieve, samort7 ?
<mroutis> it's clear, sorry
<samort7> I'm trying to add inner_hash as an element of the array x inside outer_hash
<mroutis> samort7: you are naming the keys of your outer_hash with symbols, you should reference them as symbols, not strings
<mroutis> outer_hash[:x].push...
<samort7> ah dang, that makes sense
<samort7> Stupid mistake
<samort7> >> outer_hash = { x: [] }; inner_hash = { dog: 'bark'}; outer_hash[:x].push(inner_hash); puts outer_hash;
<ruby[bot]> samort7: # => {:x=>[{:dog=>"bark"}]} ...check link for more (https://eval.in/1046645)
<mroutis> no, is not, in Rails is pretty common to use HashWithIndiferenceAccess or something like that
<mroutis> it isn't*
<samort7> Ooh, good to know :) Thanks!
<samort7> Haha, that's cool! I love that Ruby has so many "convenience" things!
<samort7> when I first learned you could call .first or .last on a hash, I was blown away haha
Nicmavr has quit [Read error: Connection reset by peer]
<mroutis> .values and .keys are useful too
<mroutis> and recently, the .transform_keys and .transform_values
Nicmavr has joined #ruby
thy0 has quit [Quit: TTFN]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<samort7> oh, thats awesome too!
_whitelogger has joined #ruby
<havenwood> 'oh, thats awesome too!'.each_char.group_by(&:itself).transform_values(&:size)
<havenwood> #=> {"o"=>4, "h"=>2, ","=>1, " "=>3, "t"=>3, "a"=>2, "s"=>2, "w"=>1, "e"=>2, "m"=>1, "!"=>1}
<mroutis> that could be an interview question, havenwood; "get the occurence of every character in a string"
mojtaba has joined #ruby
Eiam has quit [Ping timeout: 240 seconds]
nowhereman_ has quit [Ping timeout: 256 seconds]
nowhereman_ has joined #ruby
samort7 has quit [Quit: Leaving]
kent\n has quit [Ping timeout: 245 seconds]
cadillac_ has quit [Ping timeout: 240 seconds]
duderonomy has quit [Ping timeout: 268 seconds]
reber has joined #ruby
cadillac_ has joined #ruby
duderonomy has joined #ruby
Creatornator has joined #ruby
Creatornator has quit [Client Quit]
\void has joined #ruby
mojtaba has quit [Remote host closed the connection]
ur5us has quit [Remote host closed the connection]
t0x has joined #ruby
alex`` has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
quazimodo has quit [Ping timeout: 255 seconds]
quazimodo has joined #ruby
mojtaba has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mroutis has quit [Remote host closed the connection]
camilasan has quit [Read error: Connection reset by peer]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has quit [Quit: WeeChat 2.2]
camilasan has joined #ruby
ShekharReddy has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mojtaba has quit [Remote host closed the connection]
aniarya82 has joined #ruby
tdy has quit [Read error: Connection reset by peer]
\void has quit [Quit: So long, and thanks for all the fish.]
tdy has joined #ruby
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
aniarya82 has joined #ruby
DTZUZO has joined #ruby
pskosinski has quit [Ping timeout: 240 seconds]
pskosinski has joined #ruby
pskosinski has quit [Ping timeout: 240 seconds]
pskosinski has joined #ruby
tag has quit [Quit: Connection closed for inactivity]
j416 has joined #ruby
argoneus has quit [Quit: No Ping reply in 180 seconds.]
argoneus has joined #ruby
za1b1tsu has joined #ruby
maryo has joined #ruby
<maryo> Some pointers on this ruby exception would be helpful -> https://dpaste.de/G6tu
za1b1tsu has quit [Ping timeout: 240 seconds]
<havenwood> maryo: It looks like you have a String when a URI or something else that responds to #host is expected.
<havenwood> maryo: require 'uri'; URI("http://192.168.2.19:8080/").host #=> "192.168.2.19"
<havenwood> maryo: "http://192.168.2.19:8080/".host #!> NoMethodError: undefined method `host' for "http://192.168.2.19:8080/":String
<maryo> havenwood, here is the actual code https://dpaste.de/7cuO looks like it is in the expected format. Please correct me if I am wrong
eckhardt_ has joined #ruby
vondruch has joined #ruby
<havenwood> maryo: In the code you're showing it appears you're defining JENKINS_URI last on line 33 correctly as a URI. It looks like twice above that you defined it as a String, but one of those is commented and the other should get stomped on. Sanity check with p-based debugging: p JENKINS_URI
<havenwood> maryo: (It's not good practice to redefine constants. They'll warn if you do.)
<maryo> havenwood, thank you for the pointers. I will check that o/
maryo has quit [Quit: Leaving]
Puffball has joined #ruby
eckhardt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has quit [Ping timeout: 240 seconds]
psychicist__ has joined #ruby
funnel has quit [Remote host closed the connection]
funnel has joined #ruby
maryo has joined #ruby
clemens3 has joined #ruby
DTZUZO has joined #ruby
<maryo> havenwood, I have tried adding the p-based debugging to see what value it holds and I got this https://dpaste.de/2P6z and here is how I have added p debugging https://dpaste.de/pFKL just wondering what went wrong. Some inputs from you would help.
<Radar> That's quite a lot of code.
<Radar> Can you create a MCVE? https://stackoverflow.com/help/mcve
<Radar> maryo: seems like you're trimming the port number off your URL too
lypsis has quit [Quit: ZNC - http://znc.in]
<alex``> Is there a way to chain each in one imbrication?
<alex``> I have 3 imbrications
funnel has quit [Ping timeout: 256 seconds]
<alex``> client.lines.each(line) in line.queues.each(queue) in queue.agents.each.with_index(1)(agent, position)
funnel has joined #ruby
<alex``> Is there a way to condense in one imbrication
<maryo> Radar, sure
lypsis has joined #ruby
<alex``> giving (client, line, queue, agent, position)
<alex``> in one block
<alex``> instead of the 3 imbrications
funnel has quit [Ping timeout: 272 seconds]
jackrandom has quit [Quit: ZNC - https://znc.in]
jackrandom has joined #ruby
funnel has joined #ruby
mn3m has joined #ruby
<baweaver> alex``: imbrication?
<alex``> Yep
<baweaver> What's an imbrication?
<alex``> client.lines.each do |line|
<alex``> line.queues.each do |queue|
<alex``> queue.agents.each.with_index(1) do |agent, position|
<alex``> …
<alex``> I would like:
<alex``> {chaining} do |line, queue, agent, position|
<alex``> …
<alex``> instead of the 3 imbrications
<baweaver> Where are you getting the word imbrication from?
<alex``> France XD
<baweaver> That was going to bug me all night otherwise.
<alex``> It’s not an english word as well?
<baweaver> Kind of. It's archaic verbiage for an overlapping edge, like a scale
<baweaver> but I've never heard it in relation to programming
<baweaver> Anyways...
<alex``> What the correct word
<baweaver> Nested? THat's a good question
<baweaver> Both "what's a better word" and "how the devil do I do this?"
DTZUZO has quit [Ping timeout: 272 seconds]
<baweaver> Hrm.
<baweaver> My first inclination would be some form of Enumerator hack.
<alex``> Actually I would like this working functionnaly
<baweaver> because it'd essentially be a dive down into nested array-like structures.
<alex``> like giving queue.agents.map.with_index
<alex``> to return the list of agents with the context (line, queue, position)
<baweaver> Gimme a few minutes to write out a test case
mn3m has quit [Quit: mn3m]
mn3m has joined #ruby
<alex``> baweaver: Is is related to Enumarator?
<alex``> I would expect to work with any block
<alex``> client.lines.tap
<baweaver> The idea is to treat each depth traversal as a single flattened list
<baweaver> Writing it though...
<alex``> We have an initial object, and send to it a list of methods with blocks, accumulate the blocks arguments to the final call and returns value
<alex``> baweaver: Maybe there could be a hack with |(a,b,c)| ?
<baweaver> Y'know this isn't a trivial write in 20 seconds
<alex``> [[1,2,3],[4,5,6]].map { |(a,b,c)| a+b+c }
<alex``> Yep X)
dhollin3 has joined #ruby
<baweaver> >> agents = %w(bob jill sue sam); queue = proc { OpenStruct.new(agents: agents.sample(3)) }; line = proc { OpenStruct.new(queues: 3.times.map(&queue)) }; client = proc { OpenStruct.new(lines: 3.times.map(&line)) }; client.call
<ruby[bot]> baweaver: # => uninitialized constant OpenStruct ...check link for more (https://eval.in/1046660)
<baweaver> Sample data
<baweaver> >> require 'ostruct'; agents = %w(bob jill sue sam); queue = proc { OpenStruct.new(agents: agents.sample(3)) }; line = proc { OpenStruct.new(queues: 3.times.map(&queue)) }; client = proc { OpenStruct.new(lines: 3.times.map(&line)) }; client.call
<ruby[bot]> baweaver: # => #<OpenStruct lines=[#<OpenStruct queues=[#<OpenStruct agents=["sue", "bob", "sam"]>, #<OpenStruct ag ...check link for more (https://eval.in/1046661)
<baweaver> A client has 3 lines, which all have 3 queues, which all have 3 agents
<baweaver> Which I just named after people, because why not
<baweaver> Now that we have that we can test some fun
dhollinger has quit [Ping timeout: 240 seconds]
* baweaver goes back to pry
Inline has quit [Quit: Leaving]
ruschlem has joined #ruby
ruschlem has left #ruby [#ruby]
Puffball has quit [Read error: Connection reset by peer]
<baweaver> Aha!
<baweaver> Got it
<baweaver> >> agents=%w(bob jill sue sam);queue=proc{OpenStruct.new(agents:agents.sample(3))};line=proc{OpenStruct.new(queues:3.times.map(&queue))};client=proc{OpenStruct.new(lines:3.times.map(&line))};def dive(obj, *ps)ps.empty? ? obj:obj.public_send(ps[0]).flat_map{|v|dive(v, *ps[1..-1])}end;dive(client.call, :lines, :queues, :agents)
<ruby[bot]> baweaver: # => uninitialized constant OpenStruct ...check link for more (https://eval.in/1046678)
<baweaver> ...ok, I asked for that one
<baweaver> >> require 'ostruct';agents=%w(bob jill sue sam);queue=proc{OpenStruct.new(agents:agents.sample(3))};line=proc{OpenStruct.new(queues:3.times.map(&queue))};client=proc{OpenStruct.new(lines:3.times.map(&line))};def dive(obj, *ps)ps.empty? ? obj:obj.public_send(ps[0]).flat_map{|v|dive(v, *ps[1..-1])}end;dive(client.call, :lines, :queues, :agents)
<ruby[bot]> baweaver: # => ["jill", "sue", "bob", "jill", "sam", "bob", "jill", "sue", "bob", "bob", "sue", "jill", "bob", "sam ...check link for more (https://eval.in/1046679)
kent\n has joined #ruby
sameerynho has joined #ruby
Inline has joined #ruby
<baweaver> The idea is to keep digging until you hit the bottom of the "path" you want to follow. Once you do, those are the values you want to iterate on.
Puffball has joined #ruby
tag has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
<agent_white> Happy Friday/Saturday/Weekend folks. G'night!
agent_white has left #ruby [#ruby]
<baweaver> Drive by pleasantries! The fiend!
vondruch has quit [Ping timeout: 244 seconds]
vondruch has joined #ruby
nicesignal has quit [Remote host closed the connection]
funnel has quit [Ping timeout: 240 seconds]
nicesignal has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
snuz has joined #ruby
sticaz has quit [Quit: My name Heff]
mn3m has quit [Ping timeout: 272 seconds]
j416 has left #ruby ["o/"]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
tristanp has joined #ruby
drale2k_ has joined #ruby
DTZUZO has joined #ruby
vondruch has quit [Read error: Connection reset by peer]
tristanp has quit [Ping timeout: 272 seconds]
snuz has quit [Ping timeout: 256 seconds]
cats has quit [Ping timeout: 240 seconds]
cats has joined #ruby
AJA4350 has joined #ruby
za1b1tsu has joined #ruby
gheegh has joined #ruby
mikecmpbll has joined #ruby
postmodern has quit [Quit: Leaving]
za1b1tsu has quit [Ping timeout: 248 seconds]
<alex``> baweaver: Nice !!
<alex``> The intermidiate data could be preserved with a third argument no?
<alex``> def dive(object, paths, data = [object])
za1b1tsu has joined #ruby
snuz has joined #ruby
funnel has joined #ruby
<alex``> baweaver: Do you think the function is useful, or better to organize the code diffently to don’t need imbrication?
<alex``> I think `paths` could be renamed in `def-list` or something to handle arguments
<alex``> list = [:foo, :bar, :baz]
<alex``> list = [:foo, [:arg1, arg2], :bar, { x: 1, y: 2}, :baz]
thinkpad has quit [Quit: lawl]
<maryo> instead of port 8080, can someone tell why the following ruby code takes only port 80 please -> https://dpaste.de/2pN7
thinkpad has joined #ruby
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gheegh has joined #ruby
Dbugger has joined #ruby
gheegh has quit [Client Quit]
ciro has joined #ruby
gheegh has joined #ruby
<apeiros> maryo: because that's what you tell it to?
<apeiros> JENKINS_URI.to_s[0..21] # => "http://192.168.2.19:80"
<apeiros> JENKINS_URT.port # => 80
<apeiros> I have no idea why you do .to_s on a string, and i have no idea either why you perform that slicing there.
ellcs has joined #ruby
minimal_life has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<apeiros> maryo: got to go, others can certainly help you too :)
apeiros has quit [Remote host closed the connection]
tag has quit [Quit: Connection closed for inactivity]
minimal_life has quit [Quit: I am functioning within established parameters.]
mikecmpbll has quit [Quit: inabit. zz.]
Inline has quit [Quit: Leaving]
gheegh has joined #ruby
gheegh has quit [Client Quit]
FernandoBasso has joined #ruby
maryo has quit [Ping timeout: 240 seconds]
mikecmpbll has joined #ruby
aspiers has quit [Read error: Connection reset by peer]
aspiers has joined #ruby
mojtaba has joined #ruby
gix has joined #ruby
ellcs has quit [Ping timeout: 265 seconds]
mojtaba has quit [Ping timeout: 268 seconds]
Inline has joined #ruby
Inline has quit [Remote host closed the connection]
Inline has joined #ruby
Inline has quit [Remote host closed the connection]
Inline has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
Inline has quit [Read error: Connection reset by peer]
Inline has joined #ruby
Inline has quit [Read error: Connection reset by peer]
Inline has joined #ruby
mojtaba has joined #ruby
mojtaba has quit [Client Quit]
thinkpad has quit [Quit: lawl]
thinkpad has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
Azure has quit [Quit: Oops.]
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
maryo has joined #ruby
maryo has quit [Quit: Leaving]
AJA4350 has quit [Remote host closed the connection]
za1b1tsu has quit [Ping timeout: 244 seconds]
funnel has quit [Ping timeout: 248 seconds]
unshackled has left #ruby ["Leaving"]
funnel has joined #ruby
mikecmpbll has joined #ruby
thy0 has joined #ruby
DLSteve has joined #ruby
aniarya82 has joined #ruby
mojtaba has joined #ruby
savolla has joined #ruby
mojtaba has quit [Ping timeout: 240 seconds]
t0x has quit [Quit: Connection closed for inactivity]
thinkpad has quit [Quit: lawl]
thinkpad has joined #ruby
raulp has quit [Ping timeout: 256 seconds]
Some-body_ has joined #ruby
DarthGandalf has quit [Ping timeout: 268 seconds]
Some-body_ is now known as DarthGandalf
tty has quit [Ping timeout: 244 seconds]
mojtaba has joined #ruby
blood has quit [Quit: Page closed]
alfiemax has joined #ruby
Emmanuel_Chanel has quit [Read error: No route to host]
alfiemax has quit [Remote host closed the connection]
Emmanuel_Chanel has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
ciro has quit [Ping timeout: 256 seconds]
gix has quit [Quit: Client exiting]
bmurt has joined #ruby
alfiemax has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
apeiros has joined #ruby
apeiros has quit [Ping timeout: 260 seconds]
c_nick has joined #ruby
<c_nick> Whenever I open my team city triggered runs to looks at the results, I want to provide a tab where I can see my Ruby-Sinatra web server.Ideally that should result in a Same Domain Error because team city tabs are i-frames, If I give a html page with a hyper link to the web server.How can I go about it
alfiemax has quit [Remote host closed the connection]
Mike11 has joined #ruby
<Mike11> hello all
<Mike11> is there a more idiomatic way to write something like this: https://ideone.com/H7LNEM
<Mike11> ?
<Mike11> I am concerned about having to store match_data in a separate variable and having to use it to access every match
<Mike11> I like how /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ '$3.67' stores local variables for each group
<Mike11> but I am not sure why if r =~ s then doesn't do that in my case...
gheegh has joined #ruby
<Mike11> do I need to use the regular expression literal here
<Mike11> ?
savolla has quit [Ping timeout: 268 seconds]
gheegh has quit [Client Quit]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mojtaba has quit [Remote host closed the connection]
<havenwood> Mike11: One trick is that when you have the regexp first, the named captures get automatically assigned to local variables.
gheegh has joined #ruby
<havenwood> >> /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ '$3.67'; dollars #=> "3"
<ruby[bot]> havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
mojtaba has joined #ruby
gheegh has quit [Client Quit]
desperek has joined #ruby
Mike111 has joined #ruby
<Mike111> sorry, did I miss anything?
Mike11 has quit [Ping timeout: 240 seconds]
<Mike111> havenwood: https://ideone.com/H7LNEM doesn't seem to work
<havenwood> Mike11: Ah, I see what you're asking. Yeah, it's a janky syntax so I'd avoid it. Sec.
Sembei has joined #ruby
Pisuke has quit [Ping timeout: 272 seconds]
<havenwood> Mike111: You might consider: dollars, cents = r.match(s).captures
<Mike111> havenwood: is there a way to fit that into an if expression?
<Mike111> because I have an else clause
<Mike111> which should be invoked if the regular expression does not match the string
<havenwood> Mike111: puts dollars, cents if dollars
<havenwood> Mike111: Your original checks if *either* of the named captures exists. Is that what you want, or both?
<havenwood> Mike111: puts dollars, cents if dollars && cents
<Mike111> havenwood: no, I need both
<havenwood> Mike111: dollars, cents = r.match(s).captures; puts dollars, cents if dollars && cents
<Mike111> match_data = r.match(s) followed by if match_data was working for me
<Mike111> they are like 5-6 groups to be matched :(
<Mike111> so, repeating the names twice doesn't look good either
<havenwood> Mike111: Ah, I can show a better way then. But doesn't your original return truthy when *any* not *all* captures are found?
Creatornator has joined #ruby
snuz has quit [Quit: WeeChat 2.2]
<havenwood> Mike111: Ah, no, you're right.
<havenwood> err
<Mike111> havenwood: this is exactly what I want https://ideone.com/72hduy
<Mike111> havenwood: does this code look bad for a ruby a programmer?
<havenwood> Mike111: Just get rid of the `then`. It looks good!
<Mike111> and what if there are like 5-6 variables
<Mike111> ?
<havenwood> Mike111: puts match_data.captures
<havenwood> (To avoid repeating yourself.)
<Mike111> sorry if I sound a bit fastidous
<havenwood> Mike111: I think you're right to carefully consider it.
<Mike111> mmm, I am accessing them to store them into structures actually
<Mike111> outputting them to puts is here for the purposes of this minimal example
<havenwood> Mike111: You can get a hash back with: match.named_captures
<havenwood> Mike111: If it's useful, there's also: match.values_at(:cents, :etc)
<havenwood> Mike111: If you can share the full example it might reveal more opportunities - but other than the `then` what you have looks good to me.
<Mike111> I am passing these arguments to another class's constructor
<havenwood> Mike111: Positional or keyword args?
<Mike111> e.g. using MyClass.new(match[:dollars], match[:cents], ....)
<havenwood> Mike111: If they're in the same order, you could: MyClass.new(*match.captures)
<Mike111> so, I have about 6 arguments to that constructor (rubocop complains about this, and I have no idea how I can tackle that)
<Mike111> havenwood: oh, that looks really cool if it works
<havenwood> Mike111: Or if they were keyword arguments, the order doesn't matter: MyClass.new(**match.named_captures)
<Mike111> trying...
<Mike111> havenwood: in case of about six mandatory arguments to construct an object, would you use positional or keyword arguments?
<havenwood> These days, I'd always recommend considering keyword arguments. Naming tends to be a very nice way to couple code compared to position.
<havenwood> Mike111: I would recommend keywords there.
<havenwood> Mike111: It'll tend to be a bit more verbose but a lot easier to read!
<Mike111> havenwood: can keyword arguments be mandatory? (sorry if this sounds like a stupid question)
<havenwood> Mike111: Not a stupid question, and yes, you can!
<Mike111> aha, so, I'll read about them and use the **match.named_captures syntax you suggested
<Mike111> thank you very much havenwood
<Mike111> :)
<havenwood> def initialize madatory:, another_mandatory:, optional: 42, another_optional: nil
<havenwood> Mike111: You're welcome!
FernandoBasso has quit [Quit: Leaving]
snuz has joined #ruby
thinkpad has quit [Quit: lawl]
thinkpad has joined #ruby
c_nick has quit [Remote host closed the connection]
snuz has quit [Quit: WeeChat 2.2]
snuz has joined #ruby
alfiemax has joined #ruby
drale2k_ has joined #ruby
reaVer has quit [Remote host closed the connection]
alfiemax has quit [Remote host closed the connection]
kapil___ has joined #ruby
Xiti has quit [Ping timeout: 256 seconds]
desperek has quit [Ping timeout: 240 seconds]
tristanp has joined #ruby
Xiti has joined #ruby
User458764 has joined #ruby
tristanp has quit [Ping timeout: 240 seconds]
ciro has joined #ruby
raynold has joined #ruby
raynold has quit [Remote host closed the connection]
ciro has quit [Ping timeout: 240 seconds]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ciro has joined #ruby
Creatornator has joined #ruby
duderonomy has joined #ruby
UserOO7 has joined #ruby
c0ncealed2 has quit [Remote host closed the connection]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drale2k_ has joined #ruby
drale2k_ has quit [Client Quit]
c0ncealed2 has joined #ruby
juiko has joined #ruby
juiko has quit [Remote host closed the connection]
Mike111 has quit [Quit: Leaving.]
alfiemax has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
<hays> should each class have its own file?
theRealGent has joined #ruby
User458764 has quit [Client Quit]
drale2k_ has joined #ruby
User458764 has joined #ruby
<ineb> hays: its not required but makes sense in most cases imho
cadillac_ has quit [Ping timeout: 248 seconds]
User458764 has quit [Client Quit]
User458764 has joined #ruby
UserOO7 has quit [Remote host closed the connection]
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
cadillac_ has joined #ruby
User458764 has joined #ruby
<hays> im finding that when i write code, I have a real hard time going back to it and figuring out what is happening
<hays> with maybe a 2 month gap in looking at it
<hays> trying to figure out how to remedy that
User458764 has quit [Client Quit]
<ineb> i would say by practicing
<ineb> havin a good structure in the first case helps here ofc
User458764 has joined #ruby
<hays> recently i was using a nokogiri object, and one class created the object and passed it to another, for it to be used.. coming back to it, it was hard to tell how to use it
User458764 has quit [Client Quit]
UserOO7 has joined #ruby
<hays> I guess my problem there is I should have made a stronger interface.. instead of passing back a nokogiri object, pass back my own object with clearer interfaces
<ineb> i would say there is not much you can do here but relearning how nokogiri works again :)
User458764 has joined #ruby
<ineb> defining an interface makes sense if you dont need a full featured nokogiri interface object
<ineb> but if you need to do html/xml operations it doesnt make sense to create an interface
noobineer has joined #ruby
User458764 has quit [Client Quit]
<hays> right, but if i am really wanting to not be aware of xml i should also create an interface
User458764 has joined #ruby
<ineb> yes, its an good idea. but in your case it sounds like you have not implemented the logic two months ago
<hays> correct
User458764 has quit [Client Quit]
<ineb> so the only thing you can do now is learning nokogiri and write the interface
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
Emmanuel_Chanel has quit [Quit: Leaving]
User458764 has quit [Client Quit]
User458764 has joined #ruby
<hays> how do you draw out your design? UML?
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
User458764 has quit [Client Quit]
UserOO7 has quit [Remote host closed the connection]
User458764 has joined #ruby
desperek has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
mroutis has joined #ruby
ohcibi has quit [Ping timeout: 260 seconds]
User458764 has quit [Client Quit]
User458764 has joined #ruby
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
theRealGent has quit [Quit: Leaving]
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
tty has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
UserOO7 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
ptx0 has quit [Read error: Connection reset by peer]
ptx0 has joined #ruby
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
SeepingN has joined #ruby
houhoulis has joined #ruby
User458764 has joined #ruby
quazimodo has quit [Ping timeout: 272 seconds]
User458764 has quit [Client Quit]
User458764 has joined #ruby
drale2k_ has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
MyMind has joined #ruby
Sembei has quit [Ping timeout: 256 seconds]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
cadillac_ has quit [Ping timeout: 240 seconds]
User458764 has joined #ruby
cadillac_ has joined #ruby
Pisuke has joined #ruby
MyMind has quit [Ping timeout: 244 seconds]
User458764 has quit [Client Quit]
<ineb> hays: just my head :/
User458764 has joined #ruby
Mike11 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
Creatornator has quit [Quit: Textual IRC Client: www.textualapp.com]
alfiemax has quit [Remote host closed the connection]
User458764 has joined #ruby
herbmillerjr has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Ping timeout: 240 seconds]
liushooter has joined #ruby
<liushooter> >3
liushooter has quit [Quit: WeeChat 2.2]
drale2k_ has quit [Quit: Textual IRC Client: www.textualapp.com]
dviola has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
mattp__ has quit [Ping timeout: 265 seconds]
gheegh has joined #ruby
mojtaba has quit [Quit: Leaving.]
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mroutis has quit [Remote host closed the connection]
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
impermanence has joined #ruby
aniarya82 has joined #ruby
chouhoulis has joined #ruby
scrptktty has joined #ruby
ellcs has joined #ruby
tristanp has joined #ruby
chouhoulis has quit [Ping timeout: 272 seconds]
tristanp has quit [Ping timeout: 256 seconds]
cagomez has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ellcs has quit [Ping timeout: 240 seconds]
kapil___ has quit [Quit: Connection closed for inactivity]
eb0t has quit [Quit: WeeChat 2.0.1]
t0x has joined #ruby
herbmillerjr has quit [Excess Flood]
herbmillerjr has joined #ruby
houhoulis has quit []
snuz has quit [Ping timeout: 268 seconds]
snuz has joined #ruby
snuz has quit [Ping timeout: 244 seconds]
snuz has joined #ruby
Mike11 has quit [Quit: Leaving.]
snuz has quit [Ping timeout: 260 seconds]
snuz has joined #ruby
t0x is now known as t0xik
cagomez has quit [Remote host closed the connection]
snuz has quit [Ping timeout: 272 seconds]
snuz has joined #ruby
maryo has joined #ruby
fmcgeough has joined #ruby
snuz has quit [Ping timeout: 240 seconds]
johnny56_ is now known as johnny56
tty has quit [Quit: tty]
orbyt_ has joined #ruby
kapil___ has joined #ruby
maryo has quit [Ping timeout: 244 seconds]
apeiros has joined #ruby
apeiros has quit [Ping timeout: 240 seconds]
tty has joined #ruby
AJA4350 has joined #ruby
UserOO7 has quit [Quit: binarynumber.xyz]
UserOO7 has joined #ruby
UserOO7 has quit [Remote host closed the connection]
ur5us has joined #ruby
maryo has joined #ruby
apeiros has joined #ruby
apeiros has quit [Remote host closed the connection]
UserOO7 has joined #ruby
maryo has quit [Ping timeout: 256 seconds]
bmurt has joined #ruby
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
aniarya82 has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
apeiros has joined #ruby
c0ncealed2 has quit [Remote host closed the connection]
c0ncealed2 has joined #ruby
apeiros has quit [Ping timeout: 248 seconds]
Vapez has joined #ruby
Sembei has joined #ruby
Pisuke has quit [Ping timeout: 260 seconds]
quazimodo has joined #ruby
djuber has joined #ruby
MyMind has joined #ruby
Sembei has quit [Ping timeout: 256 seconds]
desperek has quit [Quit: xoxo]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
psychicist__ has quit [Ping timeout: 256 seconds]
apeiros has joined #ruby
scrptktty has quit [Quit: Connection closed for inactivity]
bmurt has joined #ruby
bmurt has quit [Client Quit]
za1b1tsu has joined #ruby
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
nicesignal has quit [Remote host closed the connection]
nicesignal has joined #ruby
Rootsudo has joined #ruby
Rootsudo has quit [Client Quit]
UserOO7 has quit [Quit: binarynumber.xyz]
reber has quit [Remote host closed the connection]
t0xik has quit [Quit: Connection closed for inactivity]
Azure has joined #ruby
t0xik has joined #ruby
patr0clus has joined #ruby
gheegh has joined #ruby
Dbugger has quit [Ping timeout: 265 seconds]
Vapez has quit [Read error: Connection reset by peer]
UserOO7 has joined #ruby
mroutis has joined #ruby
mroutis has quit [Remote host closed the connection]
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nickjj has joined #ruby
alex`` has quit [Ping timeout: 272 seconds]
ur5us has quit [Remote host closed the connection]
SCHAPiE has quit [Quit: ZNC - http://znc.in]
sameerynho has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
UserOO7 has quit [Quit: binarynumber.xyz]
UserOO7 has joined #ruby