havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.0, 2.5.3, 2.4.5: 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!
uplime has quit [Quit: WeeChat 2.2]
laaron has joined #ruby
laaron- has quit [Remote host closed the connection]
r29v has joined #ruby
tdy has quit [Remote host closed the connection]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
idiocrash has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
nowhere_man has quit [Ping timeout: 252 seconds]
uplime has joined #ruby
johnny56_ has quit [Quit: johnny56_]
johnny56 has joined #ruby
jottr has joined #ruby
jottr has quit [Ping timeout: 245 seconds]
kapil____ has quit [Quit: Connection closed for inactivity]
m0w has joined #ruby
al2o3-cr-tmp has joined #ruby
al2o3-cr is now known as Guest5049
al2o3-cr-tmp is now known as al2o3-cr
spacesuitdiver has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
m0w has quit [Ping timeout: 244 seconds]
r29v has quit [Quit: r29v]
barg has joined #ruby
<barg> How do I convert a nokogiri object alement into a string.. for example, if I am in IRB, and I do irb(main):159:0> a=doc.css('table')[0].css('tr')[0] then it shows
<barg> => #<Nokogiri::XML::Element:0x3fc15059233c name="tr" children=[#<Noko... If I do. a.to_s then it shows => "<tr><td colspan=\"2\" style=\"text-align:center\"><. Which isn't what I want.. I want that this string "#<Nokogiri::XML::Element:0x3fc15059233c name="tr" children=[#<Noko.." How do I get that string?
<phaul> barg: try #inspect
laaron- has joined #ruby
hutch has joined #ruby
laaron has quit [Remote host closed the connection]
<phaul> barg? did that give you what you wanted?
<barg> thanks, probably, i have to test it
<barg> i'm going up and downstairs at the moment doing two things at the same time
<phaul> ah :) careful then
agent_white has joined #ruby
<barg> phaul: Yes, Thanks!
<barg> that does what I wanted
<havenwood> The :. syntax looks fantastic to me.
<havenwood> .: rather
mikecmpbll has quit [Quit: inabit. zz.]
<phaul> havenwood: reddit just started discussing that, so far it's not getting much love, but not many ppl responded yet
<uplime> is it like foo.method(:bar) ?
tdy has joined #ruby
<al2o3-cr> uplime: yes.
<phaul> not really an operator.
hutch has quit [Ping timeout: 250 seconds]
<phaul> nm I deleted what I wanted to send but I left half sentence at the end :)
<uplime> al2o3-cr: thanks
<al2o3-cr> np
<phaul> Is there a better way to delete what you decide not to say than Ctrl-A Ctrl-K in weechat?
<pabs> try ctrl-u
<phaul> pabs: thanks
elomatreb has quit [Quit: mep mep]
elomatreb has joined #ruby
elomatreb has quit [Client Quit]
hutch has joined #ruby
Dbugger has quit [Ping timeout: 250 seconds]
elomatreb has joined #ruby
elomatreb has quit [Quit: mep mep]
<uplime> phaul: also ctrl+w to delete the last word
elomatreb has joined #ruby
AJA4350 has quit [Quit: AJA4350]
spacesuitdiver has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hutch has quit [Ping timeout: 268 seconds]
orbyt_ has joined #ruby
orbyt_ has quit [Ping timeout: 246 seconds]
hutch has joined #ruby
uplime has quit [Quit: WeeChat 2.2]
tdy1 has joined #ruby
tdy has quit [Ping timeout: 268 seconds]
hutch has quit [Ping timeout: 240 seconds]
dviola has quit [Quit: WeeChat 2.3]
laaron has joined #ruby
hutch has joined #ruby
laaron- has quit [Remote host closed the connection]
hutch has quit [Ping timeout: 246 seconds]
hutch has joined #ruby
guardianW has joined #ruby
kapil____ has joined #ruby
guardianW has quit [Remote host closed the connection]
cschneid has joined #ruby
GodFather has quit [Ping timeout: 245 seconds]
hutch has quit [Ping timeout: 250 seconds]
hutch has joined #ruby
cschneid has quit [Remote host closed the connection]
rkazak has quit [Quit: Sleep.....ing....]
jdeen has quit [Remote host closed the connection]
Milos has quit [Quit: ZNC 1.7.1 - https://znc.in]
rkazak has joined #ruby
Milos has joined #ruby
Bish has quit [Ping timeout: 250 seconds]
domgetter has joined #ruby
laaron- has joined #ruby
<domgetter> Is there a way to pipe to irb? e.g. echo -e "hello\nworld" | irb
gix has quit [Ping timeout: 240 seconds]
<domgetter> If I have to do it with something like ruby -r irb -e "require 'irb'" or the like, that's fine too, I just couldn't find any working examples online
laaron has quit [Remote host closed the connection]
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
goez has quit [Ping timeout: 260 seconds]
houhoulis has joined #ruby
nowhere_man has joined #ruby
cyberarm has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 240 seconds]
hutch has quit [Ping timeout: 244 seconds]
Emmanuel_Chanel has joined #ruby
goez has joined #ruby
<havenwood> domgetter: ruby -e 'binding.irb'
<havenwood> domgetter: ah, pipe to, gotcha
<havenwood> domgetter: sec
hutch has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 250 seconds]
<havenwood> domgetter: I've actually gotta run, but maybe something like: echo "meaning = 42" | ruby -e "eval STDIN.gets; binding.irb"
<havenwood> domgetter: I'll find a way later if that ^ doesn't work.
jthomas2 has joined #ruby
jthomas2 has quit [Ping timeout: 244 seconds]
laaron- has quit [Remote host closed the connection]
laaron has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
hutch has quit [Ping timeout: 244 seconds]
goez has quit [Ping timeout: 252 seconds]
goez has joined #ruby
<Iambchop> domgetter, havenwood: http://dpaste.com/1Q6GMA0
garyserj has quit [Quit: garyserj]
Xiti has quit [Quit: Xiti]
Xiti has joined #ruby
cnsvc has joined #ruby
nowhere_man has quit [Remote host closed the connection]
nowhere_man has joined #ruby
Hien has joined #ruby
elomatreb has quit [Quit: mep mep]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
elomatreb has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
Emmanuel_Chanel has joined #ruby
davidw_ has quit [Ping timeout: 244 seconds]
agent_white has quit [Quit: leaving]
elomatreb has quit [Quit: mep mep]
elomatreb has joined #ruby
_whitelogger has joined #ruby
_whitelogger has joined #ruby
Fernando-Basso has joined #ruby
ur5us has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
clemens3 has joined #ruby
dinfuehr has quit [Ping timeout: 240 seconds]
dinfuehr has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
cschneid has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
jottr has joined #ruby
cnsvc_ has quit [Ping timeout: 256 seconds]
cnsvc has quit [Ping timeout: 256 seconds]
za1b1tsu has joined #ruby
al2o3-cr has joined #ruby
cschneid has quit [Ping timeout: 272 seconds]
al2o3-cr has quit [Quit: WeeChat 2.3]
al2o3-cr has joined #ruby
cnsvc has joined #ruby
cnsvc_ has joined #ruby
sandelius has joined #ruby
dostoyevsky has quit [Quit: leaving]
MyMind has quit [Ping timeout: 268 seconds]
Pisuke has joined #ruby
al2o3-cr has quit [Ping timeout: 246 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
dostoyevsky has joined #ruby
jottr has quit [Ping timeout: 268 seconds]
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
masterasia has joined #ruby
sandelius has joined #ruby
Dbugger has joined #ruby
cnsvc_ has quit [Ping timeout: 256 seconds]
cnsvc has quit [Ping timeout: 256 seconds]
dostoyevsky has quit [Quit: leaving]
hiroaki has quit [Quit: Leaving]
dostoyevsky has joined #ruby
reber has joined #ruby
venmx has joined #ruby
rippa has joined #ruby
cnsvc_ has joined #ruby
cnsvc has joined #ruby
r3m_ has joined #ruby
Mike111 has joined #ruby
r3m_ has quit [Quit: ZNC - http://znc.in]
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cschneid has joined #ruby
domgetter has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
thunderbirdtr has quit [Quit: ZNC 1.7.1 - https://znc.in]
thunderbirdtr has joined #ruby
dviola has joined #ruby
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
al2o3-cr has joined #ruby
gix has joined #ruby
dviola has quit [Ping timeout: 245 seconds]
conta has joined #ruby
sandelius has joined #ruby
<sandelius> Happy new year everyone
<up|ime> not everyone! there's still one timezone left in 30 minutes.
<up|ime> but besides those guys, aye.
akosednar has quit [Ping timeout: 245 seconds]
<sandelius> Yeah that's true, I sometime forget that the world isn't centered around Sweden ^^
akosednar has joined #ruby
jthomas2 has joined #ruby
al2o3-cr has quit [Ping timeout: 246 seconds]
cschneid has quit [Ping timeout: 268 seconds]
<up|ime> has it ever been? :P|
jthomas2 has quit [Ping timeout: 244 seconds]
kapil____ has joined #ruby
cnsvc has joined #ruby
cnsvc_ has joined #ruby
Inline has quit [Quit: Leaving]
DTZUZO has quit [Ping timeout: 246 seconds]
za1b1tsu has quit [Ping timeout: 246 seconds]
rippa has quit [Ping timeout: 250 seconds]
Inline has joined #ruby
Mike111 has quit [Ping timeout: 250 seconds]
rippa has joined #ruby
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpbll has joined #ruby
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
reber has quit [Remote host closed the connection]
za1b1tsu has joined #ruby
AJA4350 has joined #ruby
zapata has quit [Quit: WeeChat 2.3]
meinside has quit [Quit: Connection closed for inactivity]
cnsvc_ has joined #ruby
cnsvc has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
nfk has joined #ruby
x0f has joined #ruby
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
johnny56 has quit [Ping timeout: 272 seconds]
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nowhere_man has quit [Ping timeout: 252 seconds]
nowhere_man has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
johnny56 has joined #ruby
jottr has joined #ruby
cnsvc_ has joined #ruby
cnsvc has joined #ruby
Xiti has quit [Quit: Xiti]
sandelius has joined #ruby
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
Xiti has joined #ruby
Azure has joined #ruby
za1b1tsu has quit [Ping timeout: 250 seconds]
despai has joined #ruby
za1b1tsu has joined #ruby
cschneid has joined #ruby
za1b1tsu has quit [Ping timeout: 246 seconds]
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lucasb has joined #ruby
RougeR has joined #ruby
despai has quit [Quit: ...]
sandelius has joined #ruby
ellcs has joined #ruby
rkazak has joined #ruby
cschneid has quit [Ping timeout: 245 seconds]
Aqo has joined #ruby
RougeR has quit [Ping timeout: 250 seconds]
houhoulis has joined #ruby
roshanavand has joined #ruby
dviola has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
masterasia has joined #ruby
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
davidw_ has joined #ruby
ellcs has quit [Ping timeout: 250 seconds]
ellcs has joined #ruby
rkazak has joined #ruby
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
agent_white has joined #ruby
tdy1 has joined #ruby
Exagone313 has quit [Quit: see ya!]
KeyJoo has quit [Ping timeout: 245 seconds]
tdy1 has quit [Remote host closed the connection]
<havenwood> Iambchop: Nice!
zapata has joined #ruby
uplime has joined #ruby
tdy has joined #ruby
cnsvc_ has joined #ruby
cnsvc has joined #ruby
BH23 has joined #ruby
Exagone313 has joined #ruby
hurricanehrndz has quit [Quit: Goodbye]
cschneid has joined #ruby
reber has joined #ruby
clemens3 has quit [Remote host closed the connection]
clemens3 has joined #ruby
kapil____ has joined #ruby
roshanavand has quit [Remote host closed the connection]
roshanavand has joined #ruby
Mike11 has joined #ruby
dviola has quit [Ping timeout: 245 seconds]
Swyper has joined #ruby
cschneid has quit [Ping timeout: 245 seconds]
<Swyper> &>> 1 == "1"
<rubydoc> # => false (https://carc.in/#/r/5wa0)
<Swyper> does ruby support loose comparisons like js?
<Swyper> if(year[3].to_i == 1 || year[3].to_i == 9 || year[3].to_i == 7) fixed it, but would still like to know the answer to ^
<lupine> nothing quite so insane, but sure, you can define the "==" method for most classes
<lupine> (not all of them)
<Swyper> fair
<Swyper> any idea why this test is failing o-o
dviola has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
KeyJoo has joined #ruby
<leftylink> well, you have a REPL at your disposal. you should strongly consider using it to evaluate some useful expressions
<leftylink> for example, what would 'a-z'.include?('x') be?
<havenwood> Swyper: 'a-z' doesn't expand to a range
<Swyper> I don't know what a REPL is, leftylink
<havenwood> ?irb Swyper
<ruby[bot]> Swyper: irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
<Swyper> a-z does expand to a range I thought? hm
<Swyper> &>> "xyz".count("a-z")
<rubydoc> # => 3 (https://carc.in/#/r/5wa1)
<havenwood> Swyper: It'd be a valid glob.
lucasb has quit [Quit: Connection closed for inactivity]
<havenwood> Swyper: #count uses globbing.
<Swyper> &>> "xyzUUUU".count("a-zA-Z")
<rubydoc> # => 7 (https://carc.in/#/r/5wa2)
<Swyper> hm
<havenwood> Swyper: Wherever globs are used, it's good.
<Swyper> whats globbing? or do you prefer I google it xD
<havenwood> Swyper: It's kinda like regex, but simpler. It's what shells use for file matching.
<havenwood> ls *.{exe,etc}
<leftylink> because 'a-z' is a string, to see the behaviour of 'a-z'.include?(whatever) , you would see what String#include? does.
<Swyper> &>> ('a-z').include?("b")
<rubydoc> # => false (https://carc.in/#/r/5wa3)
<leftylink> &ri String#include?
<Swyper> ah I see
<havenwood> &>> [*?a..?z]
<rubydoc> # => ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", ...check link for more (https://carc.in/#/r/5wa4)
<Swyper> what does the *? and ? do
<leftylink> &>> ?a
<rubydoc> # => "a" (https://carc.in/#/r/5wa5)
<havenwood> Swyper: ?a is a character literal for 'a'
<havenwood> Swyper: the * expands the range into its elements
<havenwood> &>> (?a..?z).size
<rubydoc> # => nil (https://carc.in/#/r/5wa6)
<havenwood> &>> [?a..?z].size
<rubydoc> # => 1 (https://carc.in/#/r/5wa7)
<havenwood> &>> [*?a..?z].size
<rubydoc> # => 26 (https://carc.in/#/r/5wa8)
<jhass> I hope ruby 3 will finally drop the ?x syntax
<havenwood> jhass: I doubt it, since it only fell out of favor with 1.8 incompatibility.
* havenwood tries to bring ?x back :P
<jhass> wasn't it introduced because String#[] used to return the codepoint?
<havenwood> jhass: yeah, I guess I could see 1.9 change as on the path to deprecation - but I don't think it'll actually be removed
Dbugger has quit [Quit: Leaving]
<jhass> too bad, it's just confusing and we shouldn't be perl
<Swyper> so here is what I attempted though I can see how to do it using what you showed me above
<Swyper> ("a-z").split.reject {|char| ("a-z").count(char) > 1 }
<Swyper> err that should be >=
<havenwood> &>> 'a-z'.split
<rubydoc> # => ["a-z"] (https://carc.in/#/r/5wa9)
<havenwood> Swyper: ^
<havenwood> Swyper: ('a'..'z')
<havenwood> &>> ('a'..'z').count
<rubydoc> # => 26 (https://carc.in/#/r/5wad)
<havenwood> &>> ('a'..'z').class
<rubydoc> # => Range (https://carc.in/#/r/5wae)
<Swyper> thats..pretty confusing why aren't the notations for ranges uniform across Ruby ?
jthomas2 has joined #ruby
<jhass> they are, ? is just confusing, forget about it
<havenwood> Swyper: Globs are just globs. They only work where globs are expected. They're like a minigame.
<havenwood> Swyper: Ranges are: thing..other_thing
<havenwood> &>> (42..100).count
<rubydoc> # => 59 (https://carc.in/#/r/5wai)
<havenwood> &ri Range
<Swyper> jhass: eh I kind of have to learn it for what I'm doing rn
<Swyper> tho I guess you could argue there are different ways to do which don't involve using those concepts :P
<havenwood> to be fair, you could never learn ?x and you'd be finne
tdy has quit [Ping timeout: 246 seconds]
<havenwood> i just have an agenda :P
<jhass> ?a == 'a', thus (?a..?z) == ('a'..'z'). the right hand variant is the common one you should remember and use, forget about the ?a stuff
<ruby[bot]> jhass: I don't see no ==, whom should I tell about a?
<jhass> haha
<Swyper> whats the agenda?
<havenwood> ?cookie ruby[bot]
<ruby[bot]> ruby[bot]: here's your cookie: 🍪
<Swyper> to get a cookie? :P
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
<Swyper> ('a'..'z').select {|char| ("a-z").count(char) >= 1 } so I'm obviously still messing up the notation somewhere still
<Swyper> >_>
<jhass> ?a
<ruby[bot]> jhass: I don't know anything about a
<havenwood> Swyper: ("a-z").count #=> 3
<havenwood> well, #size, but it's only 3
rkazak has joined #ruby
jthomas2 has quit [Ping timeout: 268 seconds]
<havenwood> Swyper: You can only use globs as an argument when it's expected. You can never use them as a receiver for methods.
<havenwood> Swyper: Don't call methods on a glob. They're just a dump string.
<Swyper> ohh
<havenwood> dumb string*
<Swyper> so the generic way to call a range from a-z is ('a'..'z') that will work in most cases?
<havenwood> Swyper: Yes, that's a valid Range of Strings.
<havenwood> &>> ('a'..'z').include? 'm'
<rubydoc> # => true (https://carc.in/#/r/5wax)
<Swyper> expected: ["a", "q", "r", "w"]
<Swyper> got: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
<Swyper> ('a'..'z').select {|char| ('a'..'z').count(char) >= 1 } ->
<Swyper> ignore the ->
tdy has joined #ruby
<havenwood> Swyper: How many "m"s are there in ("a".."z")?
<Swyper> 1
<havenwood> Swyper: So how many of char are in?: ('a'..'z').count(char)
<Swyper> 0 ?
<havenwood> Swyper: always 1
<havenwood> Swyper: or 0
<havenwood> Swyper: never > 1
<havenwood> just because our range of letters doesn't include repeats
<havenwood> abbcd
nowhere_man has quit [Ping timeout: 252 seconds]
<Swyper> I got kind of confused because I thought that a string and a character might not evaluate to true 'a' == "a" might be false
<Swyper> &>> 'a' == "a"
<rubydoc> # => true (https://carc.in/#/r/5wb2)
<Swyper> cool guess it does not work that way xD
<havenwood> &was >> ?a == 'a'
<havenwood> #=> true
<havenwood> Swyper: Just different ways to say the same thing.
<Swyper> I see
tdy has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
<Swyper> expected: ["a", "q", "r", "w"] got: []
<Swyper> ('a'..'z').reject {|char| ('a'..'z').count(char) == 1 }
<havenwood> &>> ('a'..'z').include? 'm'
<rubydoc> # => true (https://carc.in/#/r/5wb5)
tdy has joined #ruby
<Swyper> so what this line should be doing is iterating through the list of all characters, and rejected those wherever the count == 1 and sending back a list a-z where none of the elements of the list are elements of the string
<havenwood> Swyper: Checking for inclusion is a bit more straightforward than counting.
<Swyper> jeez my logic here is so bad let me rewrite
<leftylink> regarding "are elements of the string" - then logically, the code should include some reference to the string there.
<havenwood> Swyper: Every character in 'a'..'z' is in 'a'..'z' so it's expected to be empty
Mike11 has quit [Ping timeout: 250 seconds]
<Swyper> ('a'..'z').reject {|char| string.count(char) == 1 }
<leftylink> counterexample: "aardvark"
<Swyper> ('a'..'z').reject {|char| "aardvark".count(char) == 1 }
<Swyper> &>> ('a'..'z').reject {|char| "aardvark".count(char) == 1 }
<rubydoc> # => ["a", "b", "c", "e", "f", "g", "h", "i", "j", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "w", ...check link for more (https://carc.in/#/r/5wb6)
<Swyper> o-o
<eam> in rspec I want to validate that the lines in a file either 1) don't have foo, or 2) if they have /foo/ that they also have /bar/
<eam> what's the best approach?
<Swyper> I think using regex in someway if you can but I'm not to good with Ruby xD
<leftylink> I'd do something like `line !~ /bar/ || line =~ /foo` I suppose ?
<leftylink> oh wait, other way around
<eam> it's conditional, so not having either foo or bar is ok
<eam> but if it has foo, it must have bar
<leftylink> `line !~ /foo/ || line =~ /bar/` . I think I'm translating "P implies Q" right this time...
<eam> I can do expect(file).to match(/foo.*bar/) but this doesn't allow for cases where foo isn't present
<eam> do I need to just dump all the rspec syntax and do it in straight ruby?
Swyper has quit [Remote host closed the connection]
<leftylink> if it must have some rspec syntax... you could use something like `expect(file.lines).to be_all { |line| line =~ whatever }`
<leftylink> because `be_x` in general becomes `thing.x?`
<eam> ooh, that gives me a block with arbitrary ruby? I can work with that
<eam> I can just say { |line| line !~ /foo/ or line =~ /foo.*bar/
<eam> thanks :)
tdy has quit [Ping timeout: 268 seconds]
<havenwood> eam: or the new #match? is faster, since it doesn't set magic variables and such
<havenwood> but there's no #not_a_match? inversion
<eam> I was looking at match, but how do I -- yeah
<eam> and the conditional of match A or B cases
<havenwood> eam: Regexp.union
<eam> what I'm trying to do is write a serverspec spec to ensure that any ext filesystem in /etc/fstab has errors=panic set
<eam> havenwood: that just adds an | right?
<havenwood> yup
<leftylink> the error message for when the `be_all` is violated might be a bit less than ideal since it doesn't tell you exactly which line violated it. I might suggest something like `file.each_line { |line| next if line.include?('ext'); expect(line).to whatever }`
<havenwood> eam: and it saves the end directives mix if any
<leftylink> assuming I'm not violating some rspec style recommendations egregiously
<havenwood> a negative lookahead would be an option
<eam> oooh a serverspec file() doesn't have #lines
<havenwood> eam: how about?: /yup(?!nope)/
<eam> oooh
<eam> I don't think that works because I have .* in between yup and nope
<eam> so the engine is finding a solution where nope is in the wildcard
cschneid has joined #ruby
despai has joined #ruby
<havenwood> &>> 'yup blah blah nope'.match? /yup.*(?!nope)/
<rubydoc> # => true (https://carc.in/#/r/5wc3)
<havenwood> eam: seems it'd work to me ^, or am I missing something?
<havenwood> oh
<havenwood> yes, I'm missing something
<eam> :)
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #ruby
<eam> I think I mis-stated the problem too, it's either not /ext/ or /ext.*errors=panic/
<havenwood> mmm
<leftylink> maybe it'd make the test clearer anyway to do it in two stages rather than try with one regex
scrptktty has joined #ruby
dviola has quit [Read error: Connection reset by peer]
Swyper has joined #ruby
orbyt_ has joined #ruby
tdy has joined #ruby
rkazak has quit [Quit: Sleep.....ing....]
Swyper has quit [Remote host closed the connection]
thunderbirdtr has quit [Quit: ZNC 1.7.1 - https://znc.in]
thunderbirdtr has joined #ruby
Swyper has joined #ruby
<Swyper> hi
<Swyper> I can't figure out where my logic is wrong at all
<Swyper> nice
<Swyper> havenwood the topic used to say to use gist before right? how come we changed it to dpaste ?
<Swyper> just curious
<uplime> gist now requires an account iirc
<Swyper> ooh
<havenwood> ^
<leftylink> huh, haven't seen satisfy before, interesting
za1b1tsu has joined #ruby
<Swyper> if (songs[songs.index{song_name}] == songs[(songs.index{song_name})-1] || songs[songs.index{song_name}] == songs[(songs.index{song_name})+1])
<Swyper> this should get all repeat songs, not sure why its still sending me a list back with these songs in them o-o
tiff has joined #ruby
ellcs has quit [Ping timeout: 252 seconds]
roshanavand has quit [Remote host closed the connection]
<havenwood> Swyper: You might want to consider each_cons(3), but hard to tell from that snippet. Show more code?
roshanavand has joined #ruby
<Swyper> ^ all the code :P
jthomas2 has joined #ruby
cschneid has quit [Ping timeout: 250 seconds]
<uplime> what is the .index{ } syntax?
<leftylink> it's the "always return 0" syntax (sarcasm, but true in this case)
<leftylink> well, perhaps I give too much away
<uplime> oh is it just a normal block?
<leftylink> it is true that Swyper should carefully consider what `["a", "b"].index{"b"}` evaluates to
<leftylink> (and yes it is just a normal block)
<uplime> ah
<leftylink> with the associated consequences
<Swyper> that would return 1 no? leftylink
<leftylink> well
<leftylink> try it
<havenwood> Swyper: check it!
tdy has quit [Ping timeout: 246 seconds]
<leftylink> you have a REPL at your disposal
<leftylink> that's one of the best things it's to be used for
<Swyper> jeez 0
<havenwood> Swyper: "b" is truthy
<Swyper> I thought it would return the actual index of the element, what use is 0
<havenwood> everything but nil and false are truthy
<havenwood> Swyper: use parens for an argument, instead of squirrely braces for a block
<havenwood> &>> ["a", "b"].index("b")
<rubydoc> # => 1 (https://carc.in/#/r/5wcg)
jthomas2 has quit [Ping timeout: 246 seconds]
<Swyper> expected: ["da", "do"]
<Swyper> got: ["da", "da", "do", "la", "la", "la"]
despai has quit [Quit: ...]
roshanavand has quit [Remote host closed the connection]
<Swyper> updated line is : if (songs[songs.index{song_name}] == songs[(songs.index(song_name))-1] || songs[songs.index(song_name)] == songs[(songs.index(song_name))+1])
<leftylink> index{song_name}
<Swyper> that should check the element before and after the array, and return false if any of those is is a match
<Swyper> oops
tdy has joined #ruby
<Swyper> still broken
<Swyper> ill paste an updated dpaste
roshanavand has joined #ruby
despai has joined #ruby
<Swyper> Rubys so hard
despai has quit [Max SendQ exceeded]
despai has joined #ruby
conta has quit [Quit: conta]
ellcs has joined #ruby
<Swyper> any ideas?
cschneid has joined #ruby
roshanavand has quit [Remote host closed the connection]
<leftylink> well, you look at all the ways in which your computed answer differs from the expected answer, and then you tackle them one by one. for example, you see that one_week_wonders returns "di" in the result, when it should. so you figure out why it does that, and fix that
<leftylink> s/when it should/when it should not/
roshanavand has joined #ruby
<uplime> is ruby 2.6 officially out yet? or is it still in an rc?
Swyper has quit [Remote host closed the connection]
<leftylink> was the radition of releasing on christmases upheld?
<uplime> i saw something was released on christmas!
cschneid has quit [Ping timeout: 244 seconds]
<uplime> (mostly i just want the fancy `Integer "42x", exception: false` stuff)
<uplime> neat, thanks
hutch has joined #ruby
cschneid has joined #ruby
roshanavand has quit [Remote host closed the connection]
kapil____ has quit [Quit: Connection closed for inactivity]
uplime has quit [Quit: WeeChat 2.2]
cschneid has quit [Ping timeout: 246 seconds]
lytol has joined #ruby
hutch has quit [Ping timeout: 246 seconds]
despai has quit [Quit: ...]
tdy has quit [Ping timeout: 250 seconds]
za1b1tsu has quit [Remote host closed the connection]
cnsvc has joined #ruby
cnsvc_ has joined #ruby
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
masterasia has joined #ruby
<Calinou> that reminds me to update, thanks :)
garyserj has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
tdy has joined #ruby
Nicmavr has joined #ruby
uplime has joined #ruby
despai has joined #ruby
bmurt has joined #ruby
Swyper has joined #ruby
<Swyper> still working on the same problems
solocshaw has joined #ruby
cow[moo] has quit [Ping timeout: 268 seconds]
bmurt has quit [Client Quit]
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
ogres has joined #ruby
hutch has joined #ruby
DTZUZO has joined #ruby
hiroaki has joined #ruby
<up|ime> this name makes me think everything is addressed to me. :(
solocshaw has quit [Ping timeout: 272 seconds]
Swyper has quit [Remote host closed the connection]
KeyJoo has quit [Quit: KeyJoo]
<up|ime> it's interesting you write it as a keyword rather than the python-choose-arg
<up|ime> i get why they would make it a keyword if the other doesn't exist in ruby, but it'll still feel weird to write to me
despai has quit [Ping timeout: 250 seconds]
<uplime> havenwood: thats where i learned about it actually
armyriad has quit [Quit: Leaving]
<uplime> haha
<phaul> seems I caused some confusion yesterday by calling 'a-z' a string range as opposed to a normal range. I did not know that it's called a glob, I had to call it something..
<phaul> altough I made the distiction a couple of times
houhoulis has quit [Remote host closed the connection]
garyserj has quit [Quit: garyserj]
<phaul> jhass: still here?
Swyper has joined #ruby
<Swyper> is there a method to remove duplicates of a specific element in an array?
sandelius has joined #ruby
<Swyper> uniq! removes all duplicates afaik
<sandelius> "evening" everyone
<havenwood> sandelius: hi!
<phaul> sandelius: evening
<havenwood> Swyper: You could do: group_by(&:itself).map(&:first)
Eiquoh has quit [Quit: WeeChat 2.3]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<Swyper> is there another method that's simpler to remove all duplicates of a specific element, or remove all elements with a particular value in an array?
<phaul> second one is easy.. #delete
<Swyper> yeah and delete returns the deleted element so I could just add it back that way xD
<phaul> so you have an Array, and an elem, and you want to remove all but first occurance of elem, I am assuming you need to keep it at original index as well? If not then yeah just add it back..
<Swyper> I don't think its comparing the indexes if it then I will have to try another approach
<Swyper> songs.new((delete("song")))
<havenwood> Swyper: delete("song") #=> "song"
<Swyper> whoops took out the quotes xD
<havenwood> Swyper: But you're not calling #delete on an Array there ^ so it'll be NameError.
<Swyper> so song needs to be an Array
<Swyper> ?
<phaul> Swyper: the receiver of the delete method needs to be an Array.
<phaul> In ruby you have objects then a . sign and then method name. That's how you send a method (or message) to an object
<Swyper> songs.new((delete(song))), songs is an array and song is a string
hutch has quit [Ping timeout: 268 seconds]
<Swyper> songs.new((delete("xyz"))), would work but have a variable thats a string would not
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Swyper> I'm probably misunderstanding what everyone is saying >_>
<phaul> let's take that apart. songs is the receiver. new is the method.
<phaul> do you really wish to send the new method to songs? probablly not.
solocshaw has joined #ruby
<phaul> usually ppl send the new message to classes to create new objects. When you already have an object, you don't send the new method to it. You can send other methods to it, like delete
<phaul> when you just say a method name on it's own like you did with delete, it will be received by self. Whatever self is in that context.
<Swyper> oh I see
<Swyper> https://gistpages.com/posts/ruby_arrays_insert_append_length_index_remove <-- I was reading the insert part of that and trying the first thing
jottr has quit [Ping timeout: 268 seconds]
<Swyper> I get that the new keyword is probably for instantiating a new object like it is in other languages ;x
tiff has joined #ruby
cschneid has joined #ruby
<phaul> in ruby everything (mostly) is receiver . method ; even if it doesn't look like it. It's really useful if you think about your methods that way. Who's receving it, and how the receiver handles it. In other words there are no procedures or functions. just methods (aka messages) sent to objects
barg is now known as garyserj2
garyserj2 is now known as barg
<Radar> in really weird Ruby it can be things like 1::to_s
<Radar> but that's really not standard at all
<Swyper> okay so I tried this which is still wrong: songs.push(delete(song)) , songs is the the object which I am calling the push method on, the push method is supposed to give me the return value of delete(song)
al2o3-cr has joined #ruby
jottr has joined #ruby
<Swyper> oh I see now where I am probably going wrong
<Swyper> sec
cschneid has quit [Ping timeout: 246 seconds]
<Swyper> songs.push(songs.delete(song)) also failed xD
nfk has joined #ruby
<phaul> you are on the right track though
<Swyper> a.delete("b") #=> "b", is an example given in the docs for delete
<Swyper> I'm not seeing where m method is going wrong exactly
<Swyper> oof I figured it out
reber has quit [Remote host closed the connection]
hutch has joined #ruby
garyserj has joined #ruby
solocshaw has quit [Ping timeout: 268 seconds]
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tiff has joined #ruby
ellcs has quit [Ping timeout: 250 seconds]
uplime has quit [Quit: WeeChat 2.2]
Swyper has quit [Remote host closed the connection]
armyriad has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
sameerynho has quit [Ping timeout: 268 seconds]
cschneid has joined #ruby
dellavg_ has quit [Ping timeout: 250 seconds]
hutch has quit [Ping timeout: 244 seconds]
hutch has joined #ruby
cschneid has quit [Ping timeout: 272 seconds]
rkazak has joined #ruby
<barg> I have an array of string names=["bob","tod","john"] Why does the following give an error names.each { |x| puts names[x]+"zzz" } ? it says TypeError: no implicit conversion of String into Integer
hutch has quit [Ping timeout: 246 seconds]
uplime has joined #ruby
<havenwood> barg: `names` is an Array and `name` is a String.
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
<barg> names[x] should be a string shouldn't it?
<barg> sure 'asdf' is a string no question about that!
<barg> (And Ihave no string called 'name' ;-)
<barg> )
<leftylink> x successively takes on the values "bob", "tod", and "jon"
<barg> oh but I want x to take on the values 0,1,2
<leftylink> therefore, the block evaluates names["bob"] which will cause the tyep error
<barg> doh
<leftylink> well, if you want it to take on the values 0, 1, 2, there's Array#each_index for that
cschneid has joined #ruby
<barg> why does this not work [0..2].each { |x| puts names[x]+"zzz" }
<barg> isn't x an integer from that range/array 0..2 ?
<barg> this works [0..2].each { |x| puts names[x] }
Aqo has quit [Quit: ChatZilla 0.9.92-rdmsoft [XULRunner 35.0.1/20150122214805]]
<barg> but as soon as I try to concatenate something onto names[x] it fails
<havenwood> barg: What does the error say?
<barg> TypeError: no implicit conversion of String into Array
<havenwood> &>> [] + ''
<rubydoc> # => no implicit conversion of String into Array (TypeError) (https://carc.in/#/r/5wdm)
<barg> but names[x] should not be an array!
<havenwood> barg: But it is!
<barg> names is the array
cnsvc has joined #ruby
cnsvc_ has joined #ruby
<havenwood> barg: Show the code that created `names`?
<leftylink> x takes on the value 0..2, therefore names[0..2] is also an array
<barg> names=["bob","john","tod"]
<leftylink> &>> [0..2].each { |x| puts x }
<rubydoc> # => 0..2 ...check link for more (https://carc.in/#/r/5wdn)
<Iambchop> barg: compare "[0..2].each{|x| p x}" to "(0..2).each{|x| p x}"
<barg> Oh!
<Iambchop> oh, leftylink beat me to it :-)
cschneid has quit [Ping timeout: 268 seconds]
<barg> heh
<leftylink> x takesas in, the block is evaluated *once*, with x = 0..2
<havenwood> barg: 3.times { |x| }
<havenwood> &>> 3.times.to_a
<rubydoc> # => [0, 1, 2] (https://carc.in/#/r/5wdo)
<barg> I was using the wrong brackets!
<barg> I should've used round brackets
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<barg> thanks
<Iambchop> depending on your actual end goal: 3.times is probably better than the range :-), map is probably even better
<barg> well i wasn't trying to be clever ;-)
moei has quit [Quit: Leaving...]
<havenwood> barg: names.each { |name| puts name }
<havenwood> &>> names.map { |name| name.reverse }
<rubydoc> # => undefined local variable or method `names' for main:Object (NameError) (https://carc.in/#/r/5wdp)
<havenwood> &>> names.map &:reverse
<rubydoc> # => undefined local variable or method `names' for main:Object (NameError) (https://carc.in/#/r/5wdq)
<havenwood> oops
tdy has quit [Ping timeout: 272 seconds]
spacesuitdiver has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jthomas2 has joined #ruby
orbyt_ has joined #ruby
cnsvc has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 256 seconds]
jthomas2 has quit [Ping timeout: 268 seconds]
bmurt has joined #ruby
tdy has joined #ruby
ogres has quit [Quit: Connection closed for inactivity]
<barg> thanks
clemens3 has quit [Remote host closed the connection]
rkazak has quit [Quit: Sleep.....ing....]
hutch has joined #ruby
houhoulis has joined #ruby
tdy has quit [Ping timeout: 244 seconds]
spacesuitdiver has joined #ruby
houhoulis has quit []
hiroaki has quit [Ping timeout: 252 seconds]