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!
kinduff has quit [Ping timeout: 256 seconds]
gell5 has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
dfucci has quit [Ping timeout: 265 seconds]
gell5 has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
notmylinkies has quit [Ping timeout: 258 seconds]
oddp has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 272 seconds]
CrazyTux[m] has quit [Remote host closed the connection]
CrazyTux[m] has joined #ruby
CrazyTux[m] has quit [Remote host closed the connection]
gell5 has joined #ruby
TCZ has quit [Quit: Leaving]
gell5 has quit [Ping timeout: 258 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
thegeekinside has joined #ruby
duderonomy has joined #ruby
meinside has joined #ruby
gix has quit [Ping timeout: 240 seconds]
braj has joined #ruby
drincruz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
drincruz has quit [Ping timeout: 272 seconds]
thegeekinside has quit [Ping timeout: 256 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
banisterfiend has joined #ruby
cthu| has quit [Ping timeout: 258 seconds]
banisterfiend has quit [Client Quit]
CrazyTux[m] has joined #ruby
r3m has quit [Quit: WeeChat 2.9-dev]
CrazyTux[m] has quit [Remote host closed the connection]
r3m has joined #ruby
wymillerlinux has quit [Ping timeout: 240 seconds]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has joined #ruby
ur5us has joined #ruby
dfucci has joined #ruby
dfucci has quit [Ping timeout: 264 seconds]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
gueorgui has quit [Ping timeout: 256 seconds]
jetchisel has joined #ruby
drincruz has joined #ruby
gueorgui has joined #ruby
wymillerlinux has joined #ruby
mg has quit [Remote host closed the connection]
gell5 has joined #ruby
sagax has quit [Remote host closed the connection]
gell5 has quit [Ping timeout: 240 seconds]
Benett has quit [K-Lined]
Benett has joined #ruby
sagax has joined #ruby
mnathani has joined #ruby
braincrash has quit [Quit: bye bye]
arzWZM has quit [Ping timeout: 256 seconds]
arzWZM has joined #ruby
braincrash has joined #ruby
r3m has quit [Quit: WeeChat 2.9-rc1]
r3m has joined #ruby
r3m has quit [Quit: WeeChat 2.9-rc1]
r3m has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
drincruz has quit [Ping timeout: 265 seconds]
howdoi has quit [Quit: Connection closed for inactivity]
graphicsv has quit [Quit: Connection closed for inactivity]
braj has quit []
howdoi has joined #ruby
GGMethos has quit [Quit: WeeChat 2.5]
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
dfucci has joined #ruby
alfiemax has joined #ruby
sjwvuie has quit [Ping timeout: 256 seconds]
wymillerlinux has quit [Ping timeout: 246 seconds]
dfucci has quit [Ping timeout: 272 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
ChmEarl has quit [Quit: Leaving]
GGMethos has joined #ruby
schne1der has joined #ruby
schne1der has quit [Ping timeout: 258 seconds]
xco has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xco has joined #ruby
gell5 has joined #ruby
gell5 has quit [Ping timeout: 246 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bocaneri has joined #ruby
Chew has joined #ruby
cnsvc has quit [Quit: WeeChat 2.8]
cnsvc has joined #ruby
sjwvuie has joined #ruby
ur5us has quit [Ping timeout: 244 seconds]
sjwvuie has quit [Ping timeout: 272 seconds]
BenDover has joined #ruby
matthewd has quit [Ping timeout: 246 seconds]
matthewd has joined #ruby
skx86 has quit [Quit: Connection closed for inactivity]
schne1der has joined #ruby
imode has quit [Ping timeout: 246 seconds]
dualfade has quit [Ping timeout: 272 seconds]
dualfade has joined #ruby
skx86 has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
dfucci has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
alfiemax has quit [Remote host closed the connection]
sarna has joined #ruby
dfucci has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gell5 has joined #ruby
alfiemax has joined #ruby
gell5 has quit [Ping timeout: 256 seconds]
Argorok has quit [Ping timeout: 260 seconds]
peteretep has quit [Read error: Connection reset by peer]
podman has quit [Ping timeout: 244 seconds]
JayDoubleu has quit [Ping timeout: 256 seconds]
maxmanders_ has quit [Ping timeout: 244 seconds]
peteretep has joined #ruby
podman has joined #ruby
JayDoubleu has joined #ruby
maxmanders_ has joined #ruby
Industrial` has joined #ruby
alexherbo2 has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
Argorok has joined #ruby
Industrial` has quit [Ping timeout: 256 seconds]
r3m has quit [Quit: WeeChat 2.9-rc1]
Industrial` has joined #ruby
r3m has joined #ruby
ldepandis has joined #ruby
Industrial` has quit [Ping timeout: 240 seconds]
alfiemax has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 256 seconds]
sjwvuie has joined #ruby
sarna has quit [Quit: Connection closed]
sarna has joined #ruby
sjwvuie has quit [Ping timeout: 240 seconds]
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
alfiemax has joined #ruby
fercell has joined #ruby
imode has joined #ruby
fercell has quit [Ping timeout: 272 seconds]
fercell has joined #ruby
TomyWork has joined #ruby
jetpack_joe has quit [Ping timeout: 246 seconds]
hahuang65 has quit [Ping timeout: 246 seconds]
BuildTheRobots has quit [Ping timeout: 244 seconds]
alnk has quit [Ping timeout: 272 seconds]
sjwvuie has joined #ruby
fercell_ has joined #ruby
BuildTheRobots has joined #ruby
hahuang65 has joined #ruby
hahuang65 has quit [Max SendQ exceeded]
jetpack_joe has joined #ruby
hahuang65 has joined #ruby
alnk has joined #ruby
fercell has quit [Ping timeout: 256 seconds]
sjwvuie has quit [Ping timeout: 240 seconds]
Industrial` has joined #ruby
sjwvuie has joined #ruby
fercell_ has quit [Ping timeout: 260 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Industrial` has quit [Ping timeout: 240 seconds]
sjwvuie has quit [Ping timeout: 256 seconds]
alfiemax has quit [Remote host closed the connection]
fercell has joined #ruby
cnsvc has quit [Quit: WeeChat 2.8]
fercell has quit [Ping timeout: 246 seconds]
dionysus69 has joined #ruby
fercell has joined #ruby
sarna has quit [Ping timeout: 272 seconds]
dionysus69 has quit [Client Quit]
fercell has quit [Quit: WeeChat 2.8]
fercell has joined #ruby
dionysus69 has joined #ruby
gell5 has joined #ruby
alfiemax has joined #ruby
gell5 has quit [Ping timeout: 272 seconds]
ikonia has left #ruby [#ruby]
imode has quit [Ping timeout: 246 seconds]
fercell_ has joined #ruby
fercell has quit [Ping timeout: 260 seconds]
Tempesta has quit [Quit: See ya!]
Jonopoly has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
arzWZM has quit [Ping timeout: 264 seconds]
arzWZM has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
fercell_ has quit [Ping timeout: 265 seconds]
fercell_ has joined #ruby
Tempesta has joined #ruby
arahael1 has quit [Ping timeout: 260 seconds]
oddp has joined #ruby
ur5us has joined #ruby
Industrial` has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
alfiemax has joined #ruby
tau has quit [Remote host closed the connection]
arahael1 has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
sarna has joined #ruby
mossplix has joined #ruby
Industrial` has quit [Ping timeout: 260 seconds]
mossplix has quit [Remote host closed the connection]
Industrial` has joined #ruby
dfucci has joined #ruby
arahael1 is now known as Arahael
mossplix has joined #ruby
banisterfiend has joined #ruby
Jonopoly has quit [Quit: WeeChat 2.8]
banisterfiend has quit [Ping timeout: 260 seconds]
sarna has quit [Ping timeout: 246 seconds]
mossplix has quit [Remote host closed the connection]
bamdad has quit [Remote host closed the connection]
bamdad has joined #ruby
gell5 has joined #ruby
mossplix has joined #ruby
TCZ has joined #ruby
gell5 has quit [Ping timeout: 264 seconds]
Industrial` has quit [Ping timeout: 272 seconds]
jenrzzz has quit [Ping timeout: 258 seconds]
fercell_ has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
fercell_ has joined #ruby
myphs has joined #ruby
alfiemax has quit [Remote host closed the connection]
aesthe has joined #ruby
fercell_ has quit [Ping timeout: 256 seconds]
fercell_ has joined #ruby
drincruz has joined #ruby
drincruz has quit [Ping timeout: 256 seconds]
ldepandis has quit [Read error: Connection reset by peer]
sagax has quit [Remote host closed the connection]
jetchisel has quit [Ping timeout: 258 seconds]
alfiemax has joined #ruby
mossplix has quit [Remote host closed the connection]
drincruz has joined #ruby
burningserenity has joined #ruby
alfiemax has quit [Remote host closed the connection]
TCZ has quit [Quit: Leaving]
Industrial` has joined #ruby
mossplix has joined #ruby
alfiemax has joined #ruby
mossplix has quit [Remote host closed the connection]
kristian_on_linu has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
gell5 has joined #ruby
gell5 has quit [Ping timeout: 264 seconds]
Industrial` is now known as Industrial
xco has joined #ruby
ldepandis has joined #ruby
postmodern has quit [Quit: Leaving]
howdoi has joined #ruby
kristian_on_linu has quit [Remote host closed the connection]
thegeekinside has joined #ruby
ChmEarl has joined #ruby
gell5 has joined #ruby
BSaboia has joined #ruby
lmat has quit [Remote host closed the connection]
BSaboia has quit [Quit: This computer has gone to sleep]
TCZ has joined #ruby
fercell_ has quit [Ping timeout: 256 seconds]
fercell_ has joined #ruby
govg has joined #ruby
s2013 has joined #ruby
Technodrome has joined #ruby
govg has quit [Quit: leaving]
sjwvuie has joined #ruby
HisShadow_ has joined #ruby
alfiemax has quit [Remote host closed the connection]
govg has joined #ruby
sjwvuie has quit [Ping timeout: 256 seconds]
sarna has joined #ruby
govg has quit [Client Quit]
BSaboia has joined #ruby
TCZ has quit [Quit: Leaving]
govg has joined #ruby
<HisShadow_> is there a way to use native integer types in ruby?
sjwvuie has joined #ruby
<jhass> I guess you could use fiddle or ffi
<jhass> but why
<jhass> maybe you're applying the wrong tool to the job or worrying about the wrong things :)
Industrial has quit [Ping timeout: 256 seconds]
<HisShadow_> trying to write replacing a bunch of substrings in a string using hashing, but hash computations are slow since they involve big integers
Bish has joined #ruby
orbyt_ has joined #ruby
<jhass> how's "native integers" a solution to this?
<Bish> if i ruby -rprofile, it doesn't profile threads?
<HisShadow_> jhass: I don't know, seems it should be faster to just multiply 2 numbers in a register than do whatever ruby is doing. What would you suggest?
<jhass> mh
<jhass> Ruby should pretty much be doing that if the integers are small enough to fit into the registers in the first place
<jhass> but generally you don't worry about such details in Ruby, hence my "wrong tool"
<jhass> for the "right tool" I'm not sure I have enough context, but probably C (maybe a C extension for Ruby), Go, Rust or Crystal
<jhass> though I cannot know how much of the potential algorithmic wins to your problem you already applied, which will always be greater than porting
<jhass> and then of course there's trade-offs to be made between just letting the computer churn on what you got vs effort sunk into algorithmic improvements vs effort sunk into porting
ldepandis has quit [Ping timeout: 264 seconds]
teclator has quit [Ping timeout: 272 seconds]
Fischmiep has joined #ruby
gell5 has quit [Ping timeout: 264 seconds]
<HisShadow_> well, I'll experement further then, thanks
HisShadow_ has left #ruby [#ruby]
cfjk has quit [Quit: Ping timeout (120 seconds)]
mojca has quit [Ping timeout: 258 seconds]
cfjk has joined #ruby
mojca has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
sarna has quit [Ping timeout: 258 seconds]
mossplix has joined #ruby
Esa__ has joined #ruby
Industrial has joined #ruby
alfiemax has joined #ruby
FrankyCyborg has quit [Quit: The Sleep Monster got me!]
mossplix has quit [Remote host closed the connection]
fercell_ has quit [Quit: WeeChat 2.8]
howdoi has quit [Quit: Connection closed for inactivity]
arzWZM has quit [Ping timeout: 256 seconds]
arzWZM has joined #ruby
sagax has joined #ruby
UncleCid has quit [Remote host closed the connection]
UncleCid has joined #ruby
Uncle_Cid has joined #ruby
Emmanuel_Chanel has quit [Quit: Leaving]
TomyWork has quit [Remote host closed the connection]
sjwvuie has quit [Ping timeout: 246 seconds]
BSaboia has joined #ruby
teclator has joined #ruby
markong has joined #ruby
Emmanuel_Chanel has joined #ruby
sjwvuie has joined #ruby
schne1der has quit [Ping timeout: 260 seconds]
Uncle_Cid has quit [Quit: Leaving]
UncleCid has quit [Quit: Leaving]
UncleCid has joined #ruby
markoong has joined #ruby
markong has quit [Ping timeout: 272 seconds]
plutes has quit [Ping timeout: 272 seconds]
Secret-Fire has quit [Read error: Connection reset by peer]
Secret-Fire has joined #ruby
Secret-Fire has quit [Max SendQ exceeded]
Secret-Fire has joined #ruby
KeyJoo has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
Secret-Fire has joined #ruby
rippa has joined #ruby
mossplix has joined #ruby
cthu| has joined #ruby
CrazyTux[m] has joined #ruby
burningserenity has quit [Quit: Leaving.]
alfiemax has quit [Remote host closed the connection]
alfiemax_ has joined #ruby
arzWZM has quit [Read error: Connection reset by peer]
arzWZM has joined #ruby
sjwvuie has quit [Ping timeout: 258 seconds]
gell5 has joined #ruby
alfiemax has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
alfiemax_ has quit [Ping timeout: 256 seconds]
gell5 has quit [Ping timeout: 272 seconds]
plutes has joined #ruby
alexherbo2 has quit [Ping timeout: 264 seconds]
alfiemax has quit [Remote host closed the connection]
drincruz has quit [Ping timeout: 272 seconds]
drincruz has joined #ruby
howdoi has joined #ruby
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
lipoqil_ has joined #ruby
nuck_ has joined #ruby
Takumo has quit [Ping timeout: 260 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mojca_ has joined #ruby
mojca has quit [*.net *.split]
zipkid has quit [*.net *.split]
nuck has quit [*.net *.split]
lipoqil has quit [*.net *.split]
pyrmont has quit [*.net *.split]
markin has quit [*.net *.split]
finn[m] has quit [*.net *.split]
tsrt^ has quit [*.net *.split]
x0n has quit [*.net *.split]
canton7 has quit [*.net *.split]
jokester has quit [*.net *.split]
nuck_ is now known as nuck
lipoqil_ is now known as lipoqil
e has quit [Ping timeout: 606 seconds]
prkn8[m] has quit [Remote host closed the connection]
Manchotix[m] has quit [Remote host closed the connection]
Vagabond[m] has quit [Remote host closed the connection]
newalexandria[m] has quit [Write error: Connection reset by peer]
sepp2k has quit [Remote host closed the connection]
batisi[m] has quit [Read error: Connection reset by peer]
simi[m] has quit [Read error: Connection reset by peer]
doug[m]1 has quit [Read error: Connection reset by peer]
Hanma[m] has quit [Remote host closed the connection]
hsiktas[m] has quit [Write error: Connection reset by peer]
execat[m] has quit [Write error: Broken pipe]
turt2live has quit [Write error: Connection reset by peer]
tranch[m] has quit [Write error: Connection reset by peer]
greypack has quit [Ping timeout: 246 seconds]
tsrt^ has joined #ruby
zipkid has joined #ruby
pyrmont has joined #ruby
x0n has joined #ruby
markin has joined #ruby
jokester has joined #ruby
canton7 has joined #ruby
x0n has quit [Max SendQ exceeded]
x0n has joined #ruby
Takumo has joined #ruby
greypack has joined #ruby
schne1der has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
alfiemax has joined #ruby
Secret-Fire has joined #ruby
sjwvuie has joined #ruby
execat[m] has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
burningserenity has joined #ruby
alexherbo2 has joined #ruby
sjwvuie has quit [Ping timeout: 256 seconds]
schne1der has quit [Ping timeout: 256 seconds]
Secret-Fire has joined #ruby
alexherbo2 has quit [Ping timeout: 256 seconds]
sjwvuie has joined #ruby
<mnathani> If I have a string variable that contains things like {"result"=>"success", "userid"=>"2050" , how would I puts or display one element like result?
e has joined #ruby
<havenwood> mnathani: That looks like a Hash?
<havenwood> mnathani: You mean a String like?: '{"result"=>"success", "userid"=>"2050"'
<havenwood> mnathani: Or it's a Hash?
<havenwood> &>> {"result"=>"success", "userid"=>"2050"}.fetch("result")
<rubydoc> # => "success" (https://carc.in/#/r/9eaz)
sjwvuie has quit [Ping timeout: 240 seconds]
<mnathani> yup is a hash
<mnathani> new to ruby here
<havenwood> mnathani: See Hash#[], Hash#fetch, and Hash#dig.
<havenwood> mnathani: Welcome!
<mnathani> thought I was dealing with JSON this whole time
<mnathani> but then decided to validate it and it failed, so turns out I wasnt
<havenwood> mnathani: You can ask it what it is.
<havenwood> &>> {"result" => "success"}.class
<rubydoc> # => Hash (https://carc.in/#/r/9eb0)
<havenwood> mnathani: The REPL that ships with Ruby, IRB, is super handy.
<havenwood> ?irb
davispuh has joined #ruby
<mnathani> whats wrong with this line: print response["email"],response["credit"].join(",")
<havenwood> 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.
<havenwood> mnathani: The comma.
<havenwood> l"],re <--
<mnathani> what should it be instead?
<havenwood> mnathani: Are you trying to fetch two keys?
<mnathani> and is there a way to display multiple elements from a hash without specifying the hash name?
<mnathani> yes
<havenwood> mnathani: Hash#values_at
<mnathani> Thank you
<mnathani> how would I modify the output to skip the brackets and "
sjwvuie has joined #ruby
<mnathani> ["Full Name", "email@example.com", "0.00"] should just be Full Name, email@example.com, 0.00
<havenwood> mnathani: The brackets are an "Array literal."
<mnathani> hmm .. not too sure what that means
<havenwood> &>> [42, ' + ', 42, ' = ', '???'].join
<rubydoc> # => "42 + 42 = ???" (https://carc.in/#/r/9eb1)
myphs has quit [Ping timeout: 256 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
<havenwood> &>> [42, ' + ', 42, ' = ', '???'].join('...')
<rubydoc> # => "42... + ...42... = ...???" (https://carc.in/#/r/9eb2)
cacheerror has joined #ruby
newalexandria[m] has joined #ruby
turt2live has joined #ruby
batisi[m] has joined #ruby
sepp2k has joined #ruby
finn[m] has joined #ruby
Hanma[m] has joined #ruby
tranch[m] has joined #ruby
hsiktas[m] has joined #ruby
doug[m]1 has joined #ruby
prkn8[m] has joined #ruby
Manchotix[m] has joined #ruby
Vagabond[m] has joined #ruby
simi[m] has joined #ruby
Eiam has joined #ruby
Industrial has quit [Ping timeout: 265 seconds]
<mnathani> cool
<mnathani> used arr.each {|a| print a
alfiemax_ has joined #ruby
<mnathani> response.values_at("fullname","email","credit").each {|a| print a, ","}
<mnathani> but what if I dont want the trailing comma
KeyJoo has quit [Quit: KeyJoo]
<havenwood> mnathani: What method did I use in the example above?
alfiemax has quit [Ping timeout: 258 seconds]
<leftylink> I am so tempted to give the troll answer of "obviously then you print \b", but I think a troll answer is not appropriate for learning. only appropriate when the person can understand it's a troll and be able to laugh with me, instead of thinking I'm laughing at them
<havenwood> mnathani: Hint, it starts with the letter "j."
alfiemax has joined #ruby
<mnathani> aha join
<havenwood> leftylink: Backspace FTW!
<leftylink> so I will refrain from giving that answer
<adam12> havenwood: were you into seattle-style parens at one time?
<havenwood> adam12: Yup! I still lean toward Seattle style, but have capitulated to use parens only in method definition.
alfiemax_ has quit [Ping timeout: 246 seconds]
wake_of_ship has joined #ruby
<havenwood> Curses!!!
<adam12> LOL.
<adam12> That kinda reminds me of one of _why's talks. https://youtu.be/20ihzA8v89U
<adam12> (the duelling guys)
<havenwood> En garde!
<havenwood> o/
Secret-Fire has quit [Remote host closed the connection]
Secret-Fire has joined #ruby
<havenwood> &>> "o" "⚔" "️" " " "o"
<rubydoc> # => "o⚔️ o" (https://carc.in/#/r/9eb3)
<havenwood> &>> "o" "⚔" "️" "o"
<rubydoc> # => "o⚔️o" (https://carc.in/#/r/9eb4)
alfiemax has quit [Ping timeout: 240 seconds]
alfiemax has joined #ruby
sjwvuie has quit [Ping timeout: 244 seconds]
sjwvuie has joined #ruby
BSaboia has joined #ruby
sjwvuie has quit [Ping timeout: 258 seconds]
gell5 has joined #ruby
gell5 has quit [Ping timeout: 256 seconds]
alfiemax_ has joined #ruby
bocaneri has quit [Read error: Connection reset by peer]
alfiemax_ has quit [Remote host closed the connection]
alfiemax has quit [Ping timeout: 272 seconds]
<mnathani> how would I remove newline and comma characters from my hash, and replace with semicolon
<adam12> Oooh my Why book just arrived too
<adam12> mnathani: Can you gist what you already have? Those aren't normally in a Hash (tho they might be in the _source_ code that your Hash is represented as).
<mnathani> adam12: how about from an array?
<adam12> mnathani: Same deal. Those are control characters to tell Ruby how to parse the file. Once they are parsed, they are either elements in an Array, or keys/values in a Hash.
<adam12> mnathani: So it sounds like you want to format a hash as a key/value with semi-colons to divide them?
<adam12> &>> {foo: "bar", bar: "baz"}.map { _1.join("=") }.join(";")
<rubydoc> # => "foo=bar;bar=baz" (https://carc.in/#/r/9eb5)
<mnathani> this is what my hash looks like : "result"=>"success", "userid"=>"2050", "id"=>"2050",
stdedos has joined #ruby
<mnathani> I woud like any new line or comma characters within the quotes to be replaced
<adam12> mnathani: Ah. OK. In both the keys and values or just one?
<mnathani> values only
sjwvuie has joined #ruby
<adam12> mnathani: The argument to the block in this case will be a String. From there you can replace characters. https://rubyapi.org/2.7/o/string#method-i-tr
Industrial has joined #ruby
TCZ has joined #ruby
hiroaki has joined #ruby
myphs has joined #ruby
alexherbo2 has joined #ruby
hiroaki has quit [Ping timeout: 246 seconds]
Industrial has quit [Ping timeout: 240 seconds]
evilkhaoskat has joined #ruby
hiroaki has joined #ruby
evilkhaoskat has quit []
banisterfiend has joined #ruby
aesthe has quit [Quit: Leaving]
sjwvuie has quit [Ping timeout: 272 seconds]
arcaos has joined #ruby
sjwvuie has joined #ruby
burningserenity has quit [Quit: Leaving.]
gell5 has joined #ruby
sjwvuie has quit [Ping timeout: 264 seconds]
jetchisel has joined #ruby
myphs has quit [Read error: Connection reset by peer]
sjwvuie has joined #ruby
gell5 has quit [Ping timeout: 240 seconds]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sjwvuie has quit [Ping timeout: 240 seconds]
Technodrome has joined #ruby
<mnathani> String.sub(/\n/, " ;") only replaces the first new line character
<mnathani> how do I get it to replace ALL of them?
<mnathani> gsub it is
dionysus69 has quit [Ping timeout: 265 seconds]
sjwvuie has joined #ruby
<al2o3-cr> mnathani: are you trying to parse json?
<al2o3-cr> mnathani: where has the data come from?
<mnathani> data is hash or key/value
<mnathani> values contain newline or comma possibly
<mnathani> trying rto replace those wth semicolon
<mnathani> so the csv I generate works
Mia has quit [Read error: Connection reset by peer]
<mnathani> trying to do this: transform_values!(&:gsub(/\n/, " ;"))
<al2o3-cr> &>> {foo: "foo\n", bar: "bar\n"}.transform_values { |v| v.sub(/\n/, ';') }
<rubydoc> # => {:foo=>"foo;", :bar=>"bar;"} (https://carc.in/#/r/9ebk)
<al2o3-cr> &>> {foo: "foo\n", bar: "bar,"}.transform_values { |v| v.sub(/[\n,]/, ';') }
<rubydoc> # => {:foo=>"foo;", :bar=>"bar;"} (https://carc.in/#/r/9ebl)
<al2o3-cr> &>> {foo: "foo\n", bar: "bar,"}.transform_values { |v| v.delete("\n,") << ';' }
<rubydoc> # => {:foo=>"foo;", :bar=>"bar;"} (https://carc.in/#/r/9ebm)
<al2o3-cr> that's considering they're at the end of the string.
<al2o3-cr> we would have to look at you data to be certain.
<mnathani> Thank you
sjwvuie has quit [Ping timeout: 260 seconds]
<mnathani> I am pretty new to ruby
<mnathani> done some work with PHP and BASH in the past
<al2o3-cr> mnathani: oh, cool. welcome aboard! if you have more questions don't hesitate to ask :)
<mnathani> what if I wanted to substitue new line OR comma characters
<mnathani> would I have to do the .sub twice?
<al2o3-cr> mnathani: are the new line or comma always at the end of the string?
<mnathani> anywhere
<al2o3-cr> id use #delete then append a semicolon.
<al2o3-cr> oh, replace?
<al2o3-cr> so, replace and \n or , with ;?
ur5us has joined #ruby
<mnathani> yes , or \n with ;
<al2o3-cr> mnathani: use #tr
<al2o3-cr> v.tr("\n,", ';')
sjwvuie has joined #ruby
<al2o3-cr> but i think can be solved with a more sufficiently if, as you say, csv.
<al2o3-cr> mnathani: there is a CSV module in the stdlib.
<al2o3-cr> it's hard to say.
<mnathani> I am getting undefined method `tr' for nil:NilClass (NoMethodError)
wymillerlinux has joined #ruby
<al2o3-cr> mnathani: if possible, paste you code?
<mnathani> puts response.transform_values { |v| v.tr("\n,", '; ') }.values_at("fullname", ...).join(",")
<mnathani> response is : {"result"=>"success", "userid"=>"2050", ...
sjwvuie has quit [Ping timeout: 256 seconds]
<al2o3-cr> mnathani: what is: response.class
<mnathani> Hash
cnsvc has joined #ruby
<al2o3-cr> mnathani: somewhere, something is returing nil. most likely in #values_at.
<mnathani> I separated it out response.transform_values { |v| v.tr("\n,", '; ') }
<mnathani> and comment values at
<mnathani> same error
<al2o3-cr> &>> {}.values_at('foo').join(',')
<rubydoc> # => "" (https://carc.in/#/r/9ebr)
<al2o3-cr> bad example, but.
sjwvuie has joined #ruby
<havenwood> &>> {}.values_at('foo', 'bar', 'baz').join(',')
<rubydoc> # => ",," (https://carc.in/#/r/9ebs)
<havenwood> &>> {}.values_at('foo', 'bar', 'baz').compact.join(',')
<rubydoc> # => "" (https://carc.in/#/r/9ebt)
<mnathani> &>> {"result"=>"success", "userid"=>"2050"}.values_at("result").join(',')
<rubydoc> # => "success" (https://carc.in/#/r/9ebu)
<mnathani> &>> {"result"=>"success", "userid"=>"2050"}.values_at("result","userid").join(',')
<rubydoc> # => "success,2050" (https://carc.in/#/r/9ebv)
<mnathani> &>> {"result"=>"success", "userid"=>"2050"}.values_at("result","userid").join(', ')
<rubydoc> # => "success, 2050" (https://carc.in/#/r/9ebw)
<al2o3-cr> mnathani: somewhere in your hash you have a nil value.
<mnathani> thats pretty much what I had before, but I am trying to remove comma and newline
<havenwood> &>> {"result"=>"success", "userid"=>"2050"}.values_at("result", "OMGWTFBBQ", "userid").compact.join(', ')
<rubydoc> # => "success, 2050" (https://carc.in/#/r/9ebx)
<havenwood> mnathani: Show the value you have, and the return value you want?
<mnathani> &>> {"result"=>"s,ccess", "userid"=>"205\n0"}.values_at("result", "OMGWTFBBQ", "userid").compact.join(', ')
<rubydoc> # => "s,ccess, 205\n0" (https://carc.in/#/r/9eby)
<mnathani> "s;ccess, 205;0"
<mnathani> thats the intended output
reyfi9e has joined #ruby
<al2o3-cr> mnathani: #tr
<mnathani> &>> {"result"=>"s,ccess", "userid"=>"205\n0"}.transform_values { |v| v.tr("\n,", '; ') }
<rubydoc> # => {"result"=>"s ccess", "userid"=>"205;0"} (https://carc.in/#/r/9ec0)
<al2o3-cr> &>> {"result"=>"s,ccess", "userid"=>"205\n0"}.transform_values { |v| v.tr("\n,", ';') }.values.join(',')
<rubydoc> # => "s;ccess,205;0" (https://carc.in/#/r/9ec1)
<al2o3-cr> &>> {"result"=>"s,ccess", "userid"=>"205\n0"}.transform_values { |v| v.tr("\n,", ';') }.values.join(' ,')
<rubydoc> # => "s;ccess ,205;0" (https://carc.in/#/r/9ec2)
<al2o3-cr> &>> {"result"=>"s,ccess", "userid"=>"205\n0"}.transform_values { |v| v.tr("\n,", ';') }.values.join(', ')
<rubydoc> # => "s;ccess, 205;0" (https://carc.in/#/r/9ec3)
<al2o3-cr> there we go.
<al2o3-cr> or #values_at
jinie has quit [Quit: ZNC 1.6.1 - http://znc.in]
<al2o3-cr> havenwood: i'm still puddles why this works?
<al2o3-cr> &>> "o" "⚔" "️ " "o"
<rubydoc> # => "o⚔️ o" (https://carc.in/#/r/9ec6)
<havenwood> al2o3-cr: ;)
<al2o3-cr> :P
jinie has joined #ruby
<havenwood> &>> "⚔""️"
<rubydoc> # => "⚔️" (https://carc.in/#/r/9ec7)
<havenwood> &>> "⚔️".codepoints
<rubydoc> # => [9876, 65039] (https://carc.in/#/r/9ec8)
<al2o3-cr> &>> "⚔"" ️"
<rubydoc> # => "⚔ ️" (https://carc.in/#/r/9ec9)
<al2o3-cr> &>> "o" "⚔" "️ " "o"
<rubydoc> # => "o⚔️ o" (https://carc.in/#/r/9eca)
<havenwood> &>> [9876, 65039].map { _1.chr Encoding::UTF_8 }
<rubydoc> # => ["⚔", "️"] (https://carc.in/#/r/9ecb)
TCZ has quit [Quit: Leaving]
<al2o3-cr> but this works?
<havenwood> &>> [9876, 65039].map { _1.chr Encoding::UTF_8 }.join
<rubydoc> # => "⚔️" (https://carc.in/#/r/9ecc)
<al2o3-cr> &>> "️".bytes
<rubydoc> # => [239, 184, 143] (https://carc.in/#/r/9ecd)
<havenwood> &>> "️ ".ord
<rubydoc> # => 65039 (https://carc.in/#/r/9ece)
<havenwood> &>> "️ ".ord
<rubydoc> # => 65039 (https://carc.in/#/r/9ecf)
<havenwood> I meant:
<havenwood> &>> " ".ord
<rubydoc> # => 32 (https://carc.in/#/r/9ecg)
<al2o3-cr> but if you look at mine it a normal space (32)
<al2o3-cr> &>> "o" "⚔" "️ " "o".bytes
<rubydoc> # => [111, 226, 154, 148, 239, 184, 143, 32, 111] (https://carc.in/#/r/9ech)
<havenwood> al2o3-cr: nuh uh
<havenwood> &>> "️ ".codepoints
<rubydoc> # => [65039, 32] (https://carc.in/#/r/9eci)
<havenwood> al2o3-cr: ^
<havenwood> mnathani: undefined method `tr' for nil:NilClass
<havenwood> al2o3-cr: I think that 65039 snuck in your String
<al2o3-cr> havenwood: let me check :P
<al2o3-cr> havenwood: yep, it certainly did :)
<havenwood> al2o3-cr: sneaky invisible chars are sneaky
<al2o3-cr> havenwood: sure are
<al2o3-cr> :)
<mnathani> how would I skip the tr method for nil
<al2o3-cr> { |v| v.tr("\n,", ';') if v }
jinie has quit [Quit: ZNC 1.6.1 - http://znc.in]
jinie has joined #ruby
<al2o3-cr> i still don't see any \n or ,
<mnathani> Thats only one record
<mnathani> there are many more and some that do have those characterss
<mnathani> Thank you so much
<mnathani> It ran without an error this time
alexherbo2 has quit [Ping timeout: 256 seconds]
<al2o3-cr> mnathani: you're being very vague, so it's hard to help properly.
<al2o3-cr> havenwood: you fence?
<leftylink> I need to do a better job of realising and saying something when this is the case
<al2o3-cr> havenwood: i attended karate class back in the 80's
BenDover has quit [Quit: BenDover]
<al2o3-cr> mnathani: nil and false are the only falsy values in ruby; so if 0 -- will pass the conditional test.
<al2o3-cr> &>> if 0; Process.exit!; end
<rubydoc> stderr: playpen: application terminated with error code 1 (https://carc.in/#/r/9ecj)
<al2o3-cr> leftylink: you ok brother?
<leftylink> aye
<al2o3-cr> good, good!
imode has joined #ruby
wymillerlinux has quit [Remote host closed the connection]
wymillerlinux has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
wymillerlinux has quit [Remote host closed the connection]
BSaboia has joined #ruby
wymillerlinux has joined #ruby
Guest48 has joined #ruby
cliluw has quit [Quit: Leaving]
gix has joined #ruby
mossplix has quit [Remote host closed the connection]
Guest48 has quit [Client Quit]
BSaboia has quit [Quit: This computer has gone to sleep]
hiroaki has quit [Ping timeout: 246 seconds]
cliluw has joined #ruby
Guest48 has joined #ruby
BSaboia has joined #ruby
<al2o3-cr> mnathani: h = {"result"=>"s,ccess", "userid"=>"205\n0"}; r = -> (v) { v.tr("\n,", ';') }; CSV.open('blah.csv', 'w+', write_converters: r) { |csv| csv << h.values }
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
<al2o3-cr> mnathani: that's simplified.
gell5 has joined #ruby
mossplix has joined #ruby
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
wake_of_ship has quit [Ping timeout: 240 seconds]
prestorium has quit [Quit: prestorium]
gell5 has quit [Ping timeout: 256 seconds]
mossplix has quit [Remote host closed the connection]
greypack has quit [Ping timeout: 264 seconds]
Guest48 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gitter1234 has joined #ruby
jinie has quit [Quit: ZNC 1.6.1 - http://znc.in]
Guest48 has joined #ruby
Guest48 has quit [Client Quit]
mossplix has joined #ruby
banisterfiend has joined #ruby
markong has joined #ruby
Guest48 has joined #ruby
markoong has quit [Ping timeout: 272 seconds]
<havenwood> al2o3-cr: Nope, I've never used such a nimble sword.
<havenwood> al2o3-cr: That said, I've done miles of fencing.
<al2o3-cr> havenwood: was it level though? :P
<gitter1234> sorry to go off-topic but anybody here familiar with U.S. street numbering formats?
sh7d has quit [Ping timeout: 240 seconds]
<gitter1234> ie. how'd one abbreviate XXX East XXnd Street into say 1-11W57?
<havenwood> gitter1234: I'm familiar but heading out the door
<havenwood> gitter1234: This formats addys to USPS standard: https://tools.usps.com/zip-code-lookup.htm?byaddress
<havenwood> They should have an API. Haven't looked if they do.
<havenwood> There are various gems.
<gitter1234> cool thanks
<gitter1234> looked everywhere but i guess this info has been restricted after 911
BSaboia has joined #ruby
<gitter1234> thanks havenwood
<gitter1234> talk to u later
sh7d has joined #ruby
gell5 has joined #ruby
Guest48 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest48 has joined #ruby
Guest48 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drincruz has quit [Ping timeout: 258 seconds]
chamunks has quit [Quit: Don't worry I'm not gone yet.]
CrazyTux[m] has left #ruby [#ruby]
Guest48 has joined #ruby
chamunks has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest48 has quit [Client Quit]
Guest48 has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
Guest48 has quit [Client Quit]
BSaboia has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greypack has joined #ruby
jenrzzz has joined #ruby
gell5 has quit [Ping timeout: 272 seconds]
ferche23 has joined #ruby
Guest48 has joined #ruby
gell5 has joined #ruby
TCZ has joined #ruby
banisterfiend has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
stdedos has quit [Quit: Connection closed]
sjwvuie has quit [Ping timeout: 240 seconds]
gell5_ has joined #ruby
gell5 has quit [Ping timeout: 258 seconds]
<rapha> one of these days i'll create a twitter account and rant about the stupidity of making some weird conspiracy belief responsible for every little shit you don't like or can't figure out
Guest48 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<al2o3-cr> rapha: DO IT!
sjwvuie has joined #ruby