<xco>
i can’t use /folder/name_of_file not sure if i’m doing it right
<bitflipper>
@zenspider "Use assert_nil if expecting nil" - why? i agree that assert_nil is a nicer assertion, but shouldn't `assert_equal nil, foo.bar` always work?
eckhardt has joined #ruby
<bitflipper>
deprecation message in minitest btw
<elomatreb>
xco: If your path starts with / it's an absolute path, so it'd try to put in somewhere near the root direcory, where you either don't have permission or the folder doesn't exist (or both)
<xco>
elomatreb: what if i don’t want to put it in the root directory? I actually want to put in a subfolder in which that ruby file is found
<elomatreb>
Just leave off the leading slash, then it'd be a relative path. But all folders have to exist, it won't automatically create them
eckhardt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<xco>
elomatreb: thiis is what i did: File.open(__dir__ + "/" + "downloaded_images/" + "getty_images#{ image_id_num.to_s }.jpg","wb") do |file|
selim has quit [Ping timeout: 240 seconds]
<elomatreb>
(Nitpick: Calling .to_s on something in #{} is superflous, it does that automatically for you)
<xco>
oh good catch
selim has joined #ruby
vondruch has quit [Quit: vondruch]
milardovich has quit [Remote host closed the connection]
harai has joined #ruby
vondruch has joined #ruby
milardovich has joined #ruby
milardovich has quit [Remote host closed the connection]
milardovich has joined #ruby
vondruch has quit [Client Quit]
herbmillerjr has quit [Quit: Konversation terminated!]
vondruch has joined #ruby
harai has quit [Ping timeout: 255 seconds]
xco has quit [Ping timeout: 240 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
nacsurte_ has quit [Ping timeout: 255 seconds]
vondruch has quit [Client Quit]
vondruch has joined #ruby
nacsurte has joined #ruby
dymaxion_ has joined #ruby
herbmillerjr has joined #ruby
jgt1 has quit [Ping timeout: 248 seconds]
ahrs has quit [Remote host closed the connection]
nacsurte has quit [Ping timeout: 248 seconds]
dymaxion_ has quit [Ping timeout: 248 seconds]
s3nd1v0g1us has quit [Quit: tempusfugit]
ahrs has joined #ruby
s3nd1v0g1us has joined #ruby
s3nd1v0g1us has quit [Max SendQ exceeded]
s3nd1v0g1us has joined #ruby
beilabs has joined #ruby
ryanf has joined #ruby
ryanf has quit [Client Quit]
xco has joined #ruby
nacsurte has joined #ruby
hahuang61 has joined #ruby
cadillac_ has quit [Ping timeout: 240 seconds]
cadillac_ has joined #ruby
ramfjord has joined #ruby
beilabs has quit [Remote host closed the connection]
hahuang61 has quit [Ping timeout: 240 seconds]
dymaxion_ has joined #ruby
charliesome has joined #ruby
kculpis has joined #ruby
Defenestrate has joined #ruby
spheric has quit [Ping timeout: 255 seconds]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<xco>
i want to “mimic” the effect of a progress bar using a string of “#”. how do i add extrs “#” on THE SAME line?
mark_on_the_moon has joined #ruby
harfangk has joined #ruby
apparition47 has joined #ruby
milardovich has quit []
dymaxion_ has quit [Ping timeout: 240 seconds]
<synstack>
xco: print instead of puts, then end the line with a "\n"
<elomatreb>
Alternatively you can play around with ending the line with \r, if the terminal supports it you can "reprint" a line
<ruby[bot]>
iamyask: irccloud.com has no syntax highlighting, distracting formatting and loads slowly for most.
<iamyask>
Is it okay to use exception like this? ^
jgt1 has quit [Ping timeout: 240 seconds]
<elomatreb>
iamyask: It's usually considered bad practice to use exceptions for flow control. If you can avoid them, do so
jgt1 has joined #ruby
_whitelogger has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
<bitflipper>
iamyask: it depends. i don't think exceptions are free in comparison to checking for the presence of `nil`/`false`. it also depends what `Foo.alert` is raising an exception for. did it encounter some sort of fatal error? then it seems fine.
bkxd has joined #ruby
<bitflipper>
ah. `flash[:error] = e.message` doesn't seem like a good idea. they're not usually user-facing messages, and more diffilcult to translate them if you support >1 lang
vondruch has quit [Client Quit]
vondruch has joined #ruby
<bitflipper>
flash[:error] = I18n.t(e.localeKey) might work tho. if you go down that road.
<bitflipper>
sry
<bitflipper>
e.locale_key
bronson has joined #ruby
bkxd has quit [Ping timeout: 240 seconds]
nobitanobi has quit [Remote host closed the connection]
bronson has quit [Ping timeout: 240 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
_whitelogger has joined #ruby
spheric has joined #ruby
ltem has joined #ruby
kapil___ has joined #ruby
_whitelogger has joined #ruby
jamesaxl has joined #ruby
hahuang61 has joined #ruby
_whitelogger has joined #ruby
dymaxion_ has joined #ruby
jinie has quit [Read error: Connection reset by peer]
Defenestrate has quit [Quit: Leaving]
dymaxion_ has quit [Ping timeout: 248 seconds]
bruno- has quit [Read error: Connection reset by peer]
bruno- has joined #ruby
jinie has joined #ruby
alex`` has joined #ruby
uZiel has joined #ruby
sdjlasjdkyask has quit [Quit: Connection closed for inactivity]
lasey has quit [Ping timeout: 240 seconds]
lasey has joined #ruby
ptx0 has quit [Quit: Reconnecting]
gixxer1k has joined #ruby
mark_on_the_moon has quit [Remote host closed the connection]
ptx0 has joined #ruby
nofxxxx has joined #ruby
nofxxx has quit [Ping timeout: 240 seconds]
runescape07rsps has quit [Ping timeout: 248 seconds]
harai has quit [Ping timeout: 248 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
Cohedrin_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Cohedrin_ has joined #ruby
Dimik has quit [Ping timeout: 240 seconds]
_asqrd has joined #ruby
ryzokuken has joined #ruby
ryzokuken has quit [Remote host closed the connection]
_asqrd has quit [Quit: Leaving]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
hahuang61 has joined #ruby
kn-928 has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
ramfjord has quit [Ping timeout: 240 seconds]
jordanm has joined #ruby
hahuang61 has quit [Ping timeout: 240 seconds]
kn-928 has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
arvindsaik has quit [Ping timeout: 246 seconds]
bkxd has joined #ruby
arvindsaik has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
bkxd has joined #ruby
jameser has joined #ruby
ramfjord has joined #ruby
ramfjord has quit [Ping timeout: 240 seconds]
jamesaxl has quit [Read error: Connection reset by peer]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jamesaxl has joined #ruby
enterprisey has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
harai has joined #ruby
nhhc_ has joined #ruby
nhhc has joined #ruby
nhhc_ has quit [Read error: Connection reset by peer]
bkxd has quit [Ping timeout: 248 seconds]
gixxer1k has quit [Ping timeout: 248 seconds]
gusrub has joined #ruby
vondruch has quit [Quit: vondruch]
ramfjord has joined #ruby
vondruch has joined #ruby
bronson has joined #ruby
kies has joined #ruby
bkxd has joined #ruby
ramfjord has quit [Ping timeout: 240 seconds]
bronson has quit [Ping timeout: 255 seconds]
scottj has quit [Quit: leaving]
gusrub has quit [Remote host closed the connection]
ta_ has joined #ruby
Defenestrate has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
gusrub has joined #ruby
ta_ has quit [Ping timeout: 240 seconds]
Defenestrate has quit [Quit: Leaving]
Defenestrate has joined #ruby
gusrub has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
Defenestrate has quit [Quit: Leaving]
kn-928 has joined #ruby
kn-928 has quit [Ping timeout: 240 seconds]
gixxer1k has joined #ruby
gusrub has joined #ruby
enterprisey has quit [Quit: Leaving]
vondruch has quit [Quit: vondruch]
gusrub has quit [Remote host closed the connection]
vondruch has joined #ruby
Cohedrin_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rippa has joined #ruby
_main_ has joined #ruby
vondruch has quit [Quit: vondruch]
_main_ has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
__main__ has quit [Read error: No route to host]
_main_ has joined #ruby
_main_ has quit [Read error: Connection reset by peer]
__main__ has joined #ruby
conta has joined #ruby
biberu has joined #ruby
vondruch has quit [Quit: vondruch]
DoubleMalt has joined #ruby
vondruch has joined #ruby
hanmac has quit [Ping timeout: 240 seconds]
jameser has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
hanmac has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
kies has quit [Ping timeout: 240 seconds]
beilabs has quit [Remote host closed the connection]
hahuang61 has joined #ruby
hahuang61 has quit [Ping timeout: 255 seconds]
high_fiver has joined #ruby
sameerynho has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
madgen has joined #ruby
naftilos76 has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
marr has joined #ruby
Paraxial has quit [Read error: Connection reset by peer]
MrBusiness has quit [Ping timeout: 246 seconds]
alex``` has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
itat has joined #ruby
bronson has joined #ruby
jackjackdripper has quit [Quit: Leaving.]
Paraxial has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
bronson has quit [Ping timeout: 276 seconds]
jamesaxl has quit [Read error: Connection reset by peer]
mikecmpbll has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
zapata has quit [Ping timeout: 240 seconds]
DTZUZO has joined #ruby
eljimmy has quit [Quit: This computer has gone to sleep]
dymaxion_ has joined #ruby
gixxer1k has quit [Ping timeout: 248 seconds]
alex``` has quit [Quit: WeeChat 1.9]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dymaxion_ has quit [Client Quit]
harai has quit [Ping timeout: 240 seconds]
TomyLobo has joined #ruby
dymaxion_ has joined #ruby
FastJack has quit [Read error: Connection reset by peer]
jameser has joined #ruby
Tempesta has quit [Quit: See ya!]
FastJack has joined #ruby
minimalism has quit [Quit: minimalism]
zapata has joined #ruby
dymaxion_ has quit [Client Quit]
uZiel has quit [Ping timeout: 268 seconds]
FastJack has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
dymaxion_ has joined #ruby
jamesaxl has joined #ruby
dymaxion_ has quit [Client Quit]
vondruch has quit [Client Quit]
vondruch has joined #ruby
madgen has quit [Ping timeout: 240 seconds]
raynold has quit [Quit: Connection closed for inactivity]
jamesaxl has quit [Read error: Connection reset by peer]
jameser_ has joined #ruby
jamesaxl has joined #ruby
jameser has quit [Ping timeout: 248 seconds]
Cohedrin_ has joined #ruby
Cohedrin_ has quit [Client Quit]
charliesome has joined #ruby
tvw has joined #ruby
FastJack has joined #ruby
tvw has quit [Client Quit]
gixxer1k has joined #ruby
jgt1 has quit [Ping timeout: 255 seconds]
konsolebox has quit [Ping timeout: 240 seconds]
madgen has joined #ruby
konsolebox has joined #ruby
lasey has quit [Ping timeout: 240 seconds]
lasey has joined #ruby
davic has joined #ruby
Tempesta has joined #ruby
jgt1 has joined #ruby
dymaxion_ has joined #ruby
dymaxion_ has quit [Client Quit]
ta_ has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ta_ has quit [Ping timeout: 240 seconds]
jameser_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jameser has joined #ruby
jameser has quit [Client Quit]
kapil___ has joined #ruby
Guest22828 has quit [Read error: Connection reset by peer]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
jameser has joined #ruby
hahuang61 has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
lasey has quit [Ping timeout: 240 seconds]
harfangk has quit [Ping timeout: 240 seconds]
lasey has joined #ruby
dymaxion_ has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hahuang61 has quit [Ping timeout: 255 seconds]
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
xco has joined #ruby
xco has quit [Read error: Connection reset by peer]
xco has joined #ruby
Defenestrate has joined #ruby
aspiers has quit [Ping timeout: 240 seconds]
lupine has quit [Ping timeout: 255 seconds]
aspiers has joined #ruby
harfangk has joined #ruby
quobo has joined #ruby
lupine has joined #ruby
kristofferR has joined #ruby
madgen has quit [Ping timeout: 240 seconds]
jameser has joined #ruby
dymaxion_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
jameser has quit [Client Quit]
vondruch has quit [Client Quit]
vondruch has joined #ruby
dymaxion_ has joined #ruby
madgen has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
bronson has joined #ruby
biberu has quit []
sepp2k has joined #ruby
bronson has quit [Ping timeout: 240 seconds]
olspookishmagus has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
dymaxion_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jgt1 has quit [Ping timeout: 248 seconds]
xco has quit [Quit: xco]
vondruch has quit [Quit: vondruch]
biberu has joined #ruby
vondruch has joined #ruby
uZiel has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
karthick has joined #ruby
harfangk has quit [Quit: No Ping reply in 180 seconds.]
harfangk has joined #ruby
naftilos76 has quit [Quit: Αποχώρησε]
madgen has quit [Quit: Lost terminal]
lasey has quit [Ping timeout: 240 seconds]
lasey has joined #ruby
t-recx has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
MrBusiness has joined #ruby
karthick has quit [Ping timeout: 255 seconds]
runescape07rsps has joined #ruby
vondruch has quit [Quit: vondruch]
mikecmpbll has quit [Quit: inabit. zz.]
vondruch has joined #ruby
jameser has joined #ruby
Puffball has quit [Ping timeout: 255 seconds]
xco has joined #ruby
DaniG2k has joined #ruby
weaksauce has quit [Read error: Connection reset by peer]
dymaxion_ has joined #ruby
itat has quit [Ping timeout: 246 seconds]
ta_ has joined #ruby
TomyLobo has quit [Ping timeout: 255 seconds]
ta_ has quit [Ping timeout: 240 seconds]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jameser has joined #ruby
hahuang61 has joined #ruby
Puffball has joined #ruby
hahuang61 has quit [Ping timeout: 240 seconds]
dymaxion_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jonh>
is there a recommended tool for creating new ruby projects?
<havenwood>
jonh: Do you mean apps or gems or both?
vondruch has quit [Client Quit]
vondruch has joined #ruby
<jonh>
apps since i'm pretty new, but knowledge of both would be good since i'll eventually make gem
<bitflipper>
`bundle gem foo` works okay for creating new libraries/gems and even cmd line tools
<havenwood>
jonh: For apps it'll depend on the framework.
gixxer1k has quit [Ping timeout: 246 seconds]
<iamyask>
hey, I was wondering if its okay to use exception in controllers like this:
<bitflipper>
we answered iamyask
<iamyask>
begin
<iamyask>
ensure
<iamyask>
flash[:error] = e.message
<iamyask>
rescue e
<iamyask>
flash[:success] = Alert.foo
<iamyask>
redirect_to :back
<bitflipper>
it's been answered
<iamyask>
Ah! Sorry, i can't see the message :/
<havenwood>
iamyask: Please use a gist for more than three lines.
segy has joined #ruby
<bitflipper>
iamyask: it depends. i don't think exceptions are free in comparison to checking for the presence of `nil`/`false`. it also depends what `Foo.alert` is raising an exception for. did it encounter some sort of fatal error? then it seems fine.
<bitflipper>
ah. `flash[:error] = e.message` doesn't seem like a good idea. they're not usually user-facing messages, and more diffilcult to translate them if you support >1 lang
<bitflipper>
flash[:error] = I18n.t(e.localeKey) might work tho. if you go down that road.
<thinkpad>
ruby was created by a nice japanese fellow
<bitflipper>
sry, e.locale_key
<bitflipper>
6:00 AM E<elomatreb> iamyask: It's usually considered bad practice to use exceptions for flow control. If you can avoid them, do so
<bitflipper>
also
<havenwood>
jonh: I'd personally recommend creating a simple Rack app. Then convert it to a Roda app and try a few plugins.
<havenwood>
jonh: Rails has the most popular app generators.
<thinkpad>
japanese folks take great pride in their creations, you know
<jonh>
havenwood: thanks i'll look into those
<iamyask>
Thanks @bitflipper! That makes sense.
<havenwood>
jonh: Most Ruby webapps are Rack apps of one sort or another.
<havenwood>
jonh: So it's nice to know how to make a simple pure Rack app.
<apeiros>
iamyask: a piece of code which can be stored in a variable and executed whenever
<pinksandles>
yeah.. doc description is better than that
<pinksandles>
Proc objects are blocks of code that have been bound to a set of local variables. Once bound, the code may be called in different contexts and still access those variables.
<iamyask>
That makes sense! Thanks apeiros and pinksandles :)
jinie has quit [Read error: Connection reset by peer]
Mon_Ouie has joined #ruby
<pinksandles>
ur welcome
jinie has joined #ruby
SqREL has joined #ruby
vondruch has quit [Quit: vondruch]
quobo has quit [Quit: Connection closed for inactivity]
<apeiros>
`foo: bar` is short hand for `{:foo => bar}`
<apeiros>
and when you pass it to a method (not function), it's usually keyword arguments (instead of positional arguments)
<bougyman>
they're keyword arguments.
<bougyman>
yes, what he said.
vondruch has quit [Client Quit]
vondruch has joined #ruby
jgt2 has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
jgt1 has quit [Ping timeout: 240 seconds]
<iamyask>
I see. Thanks! btw when you said "when you pass it to a method (not function)", whats the difference b/w these two?
<iamyask>
apeiros: ^
vondruch has quit [Client Quit]
vondruch has joined #ruby
<apeiros>
ruby doesn't really have functions. functions are without a concept of "self". methods belong to an object, the receiver, which is accessible via self.
nobitanobi has joined #ruby
chouhoulis has joined #ruby
<apeiros>
procs/blocks are what come clostest to functions in ruby. but since they are more than functions, I wouldn't use that term for them either
<iamyask>
Aha! What about class methods ?
<apeiros>
what about them?
<apeiros>
their self is the class
<iamyask>
They are neither Procs or Method(since they don't belong to a particular object)
<apeiros>
you can try it
<apeiros>
class Foo; def self.class_method; p my_self_is: self; end; end
<apeiros>
Foo.class_method
<apeiros>
they are methods, as said, they belong to the class
<apeiros>
classes are objects ;-)
jhass has quit [Ping timeout: 240 seconds]
<iamyask>
Cool! Thanks! it
<iamyask>
*its a bit confusing, is there any blog/link which you can recommend for more reading on this?
Mon_Ouie has quit [Ping timeout: 240 seconds]
nobitanobi has quit [Remote host closed the connection]
jhass has joined #ruby
ta_ has joined #ruby
SR__Sebastian has joined #ruby
alfiemax has joined #ruby
ta_ has quit [Ping timeout: 240 seconds]
DoubleMalt has quit [Ping timeout: 276 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
<SR__Sebastian>
Hello there! I am quite new to Ruby and made an IMAP script. I can log in and also to catch an exception If the login fails. However I want to know if I can´t login because I mistyped my password or if e.g. the Internet connection is down. But I have no idea on how to get a return value or something out of that IMAP-login function. Here is the pastebin: https://pastebin.com/jiAD4z2Q - any ideas on where to
<havenwood>
SR__Sebastian: If you show more code we'll be able to give better advice.
<havenwood>
SR__Sebastian: File inherits from IO. Use File when dealing with Files.
astrobunny has joined #ruby
SR__Sebastian has quit [Quit: Leaving]
SR__Sebastian has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
astrobunny has quit [Ping timeout: 240 seconds]
rrode has quit [Ping timeout: 240 seconds]
marr has joined #ruby
rrode has joined #ruby
chouhoulis has quit [Remote host closed the connection]
beilabs has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
bronson has joined #ruby
_aeris_ has quit [Remote host closed the connection]
cdg has joined #ruby
conta has joined #ruby
_aeris_ has joined #ruby
bronson has quit [Ping timeout: 240 seconds]
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
harai has joined #ruby
<funkytwig>
this is verry odd, for
<funkytwig>
if when_array[0].upcase=='SUNDAY' && when_array[1].upcase ='LUNCH' then
<funkytwig>
I get 'Exception `NoMethodError' at scrape_web_olddukebri.rb:31 - undefined method `upcase=' for "Lunch":String
<funkytwig>
'
<havenwood>
funkytwig: use spaces
<funkytwig>
havenwood, silly me, I had = not ==;(
_aeris_ has quit [Remote host closed the connection]
ta_ has joined #ruby
_aeris_ has joined #ruby
SR__SebastianR has joined #ruby
ta_ has quit [Ping timeout: 240 seconds]
SR__Sebastian has quit [Ping timeout: 240 seconds]
SqREL has quit [Remote host closed the connection]
weaksauce has joined #ruby
DTZUZU has joined #ruby
SR__SebastianR has quit [Quit: Leaving]
ta_ has joined #ruby
manjaro-kde5- has joined #ruby
manjaro-kde5- has quit [Client Quit]
astrobunny has joined #ruby
chouhoulis has joined #ruby
astrobunny has quit [Ping timeout: 240 seconds]
chouhoulis has quit [Ping timeout: 240 seconds]
beilabs has joined #ruby
SqREL has joined #ruby
username_ has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
SqREL has quit [Ping timeout: 248 seconds]
Dark_Arc has joined #ruby
Dark_Arc has quit [Client Quit]
Dark_Arc has joined #ruby
Dark_Arc has quit [Client Quit]
Dark_Arc has joined #ruby
astrobunny has joined #ruby
astrobunny has quit [Ping timeout: 248 seconds]
harai has quit [Ping timeout: 246 seconds]
conta has quit [Ping timeout: 255 seconds]
d0nn1e has joined #ruby
mikecmpbll has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
alfiemax has quit [Remote host closed the connection]
alfiemax has joined #ruby
alfiemax has quit [Ping timeout: 248 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
hahuang61 has joined #ruby
nofxxxx has quit [Quit: Leaving]
nofxx has joined #ruby
hahuang61 has quit [Ping timeout: 246 seconds]
belmoussaoui has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
nobitanobi has joined #ruby
bronson has joined #ruby
vondruch has quit [Client Quit]
AndBobsYourUncle has joined #ruby
vondruch has joined #ruby
AndBobsYourUncle has quit [Client Quit]
AndBobsYourUncle has joined #ruby
AndBobsYourUncle has quit [Client Quit]
bronson has quit [Ping timeout: 248 seconds]
AndBobsYourUncle has joined #ruby
AndBobsYourUncle has quit [Client Quit]
enterprisey has joined #ruby
tomphp has joined #ruby
uZiel has quit [Ping timeout: 268 seconds]
t-recx has quit [Quit: t-recx]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
AndBobsYourUncle has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AndBobsYourUncle has quit [Client Quit]
AndBobsYourUncle has joined #ruby
AndBobsYourUncle has quit [Client Quit]
AndBobsYourUncle has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
AndBobsYourUncle has quit [Client Quit]
vondruch has quit [Client Quit]
jamesaxl has joined #ruby
AndBobsYourUncle has joined #ruby
vondruch has joined #ruby
AndBobsYourUncle has quit [Client Quit]
AndBobsYourUncle has joined #ruby
AndBobsYourUncle has quit [Client Quit]
cout has joined #ruby
ramfjord has joined #ruby
raynold has joined #ruby
tomphp has joined #ruby
tomphp has quit [Client Quit]
nobitanobi has quit [Remote host closed the connection]
astrobunny has joined #ruby
username_ has quit [Ping timeout: 240 seconds]
astrobunny has quit [Ping timeout: 240 seconds]
Asher has quit [Quit: Leaving.]
howdoi has quit [Quit: Connection closed for inactivity]
t-recx has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
x|h has joined #ruby
rrode has quit [Ping timeout: 240 seconds]
tomphp has joined #ruby
bruno- has joined #ruby
dstrunk has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has quit [Client Quit]
vondruch has quit [Quit: vondruch]
jamesaxl has quit [Quit: WeeChat 1.8]
segy has quit [Ping timeout: 240 seconds]
vondruch has joined #ruby
<darix>
funkytwig: that's why some people recommend to have the constant value first
cdg has quit [Remote host closed the connection]
vondruch has quit [Client Quit]
lexruee has quit [Ping timeout: 240 seconds]
cdg has joined #ruby
bruno-_ has joined #ruby
segy has joined #ruby
vondruch has joined #ruby
bruno- has quit [Ping timeout: 248 seconds]
cdg has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
nobitanobi has joined #ruby
dennisvennink has joined #ruby
cdg has joined #ruby
runescape07rsps has quit [Ping timeout: 240 seconds]
SteenJobs has joined #ruby
nobitanobi has quit [Remote host closed the connection]
bkxd has quit [Ping timeout: 240 seconds]
tvw has joined #ruby
hahuang61 has joined #ruby
nostalgiccloud has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
hahuang61 has quit [Ping timeout: 240 seconds]
s3nd1v0g1us has quit [Quit: tempusfugit]
astrobunny has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
dviola has joined #ruby
tvw has quit []
TomyLobo has joined #ruby
SteenJobs has quit [Quit: SteenJobs]
SteenJobs has joined #ruby
vondruch has quit [Quit: vondruch]
enterprisey has quit [Ping timeout: 276 seconds]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
beilabs has quit [Remote host closed the connection]
canteen4 has joined #ruby
aduabu has joined #ruby
<aduabu>
Hey folks
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
canteen4 has quit [Ping timeout: 240 seconds]
bronson has joined #ruby
astrobunny has quit [Ping timeout: 240 seconds]
Rodya_ has joined #ruby
enterprisey has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
ur5us has joined #ruby
Rodya_ has quit [Remote host closed the connection]
alex`` has quit [Quit: WeeChat 1.9]
bronson has quit [Ping timeout: 240 seconds]
ur5us has quit [Remote host closed the connection]
<aduabu>
Let's say I have 2 arrays, one is like a pack of cigarrette with different brands of ciggarrettes and second array is like a dozen of different brand of cigarrette packs, and I want to be able to pick a pack of malboro from the second array if someone pick a stick of malboro from first array. I think I can use subscribe method to do it but it looks too much of code for it, can anyone advise me
<aduabu>
on a more simple way to achieve this? Thanks.
<havenwood>
"it is easier for humans to understand complex data compared with complex logic"
vondruch has quit [Client Quit]
vondruch has joined #ruby
canteena has joined #ruby
<havenwood>
canteen4: Even a contrived example will do. I have `[1, 2, 3]` and `{1 => 42, 2 => 84}` and I want `{1 => 42, 2 => 82, 3 => nil}` for example.
dionysus69 has quit [Ping timeout: 240 seconds]
<havenwood>
canteen4: Your psudocode looks like an array of arrays with just false and true value. So I don't think that's what you mean.
gusrub has quit [Remote host closed the connection]
canteen4 has quit [Ping timeout: 255 seconds]
S007 has quit [Ping timeout: 246 seconds]
<canteena>
The thing is a like sticks = ["first" => "malboro", "second" => "kent], packs=[{"brand" => "malboro", "type" = "light"}, {"brand" => "kent", "type" => "menthol"}]
<canteena>
so I want a situation where if the case is stick.first from correspond to pack.malboro
<canteena>
I read you havenwood
gixxer1k has quit [Quit: Leaving]
<havenwood>
canteena: What's the result you want? What return value?
<canteena>
But it all have be inside that loop
<havenwood>
given that `sticks` and `packs`, what result do you want?
<canteena>
I want packs
<havenwood>
oh, given sticks, you want packs?
<canteena>
Yes exactly
<havenwood>
canteena: so you have: sticks = {"first" => "malboro", "second" => "kent"}
<canteena>
I want the packs object
<havenwood>
canteena: and you want: packs = [{"brand" => "malboro", "type" => "light"}, {"brand" => "kent", "type" => "menthol"}]
<canteena>
yes
<havenwood>
canteena: Where does the `"light"` from `{"type" => "light"}` come from?
<havenwood>
canteena: You seem to have only shown one half of the input data.
<canteena>
as you can see the packs array contain objects
vondruch has quit [Quit: vondruch]
<havenwood>
you can't get from sticks to packs in your example without additional information
<havenwood>
show us
vondruch has joined #ruby
<canteena>
so I want to tie the stick string to the pack object
<havenwood>
you haven't shown enough
<go|dfish>
they have both sticks and packs - they want to process each item in sticks and lookup the corresponding item in packs based on the brand name
<havenwood>
so packs isn't desired output? i'm confused...
<canteena>
yea but after iteration the sticks becomes a string while the packs becomes an object
ltem has quit [Quit: Leaving]
<canteena>
I want to be able to get hold of the pack object so I want list more of it's attributes
<havenwood>
canteena: So is `packs` the return value you want or not? Can you just show the input values you have and the output value you want?
<canteena>
Yea I want to get this packs.collect{|pack| }
<havenwood>
What value does that return?
Dimik has quit [Ping timeout: 240 seconds]
<canteena>
I can do packs.each{|pack| puts pack} normally
<havenwood>
I'm still unclear if you mean given `sticks` and `packs` you want a third as-yet unseen thing, or if you mean given `sticks` and some as-yet unseen thing the return value is `packs`.
<havenwood>
canteena: Forget the psudocode. What is the return value you seek?
vondruch has quit [Client Quit]
vondruch has joined #ruby
SqREL has joined #ruby
<canteena>
but I want to be able to do sticks.collect{|stick| packs.collect{|pack| p = "#{pack} == #{stick} pack.type}}
<canteena>
but I want to be able to do sticks.collect{|stick| packs.collect{|pack| p = "#{pack} == #{stick} p.type}}
<havenwood>
So you want???: [[true, false, false], [false, false, false]]
<canteena>
The second one is the actual thing I hope to achieve
<canteena>
but I want to be able to do sticks.collect{|stick| packs.collect{|pack| p = "#{pack} == #{stick} p.type}}
<havenwood>
canteena: You must want a return value. What is it?
<canteena>
I want to return p = "#{pack} == {stick}"
<havenwood>
canteena: Like I have `2` and `2`. I want `4`.
<havenwood>
canteena: You want to return a single string, given `sticks` and `packs`?
<havenwood>
canteena: Please look at what the output value example looks like.
<canteena>
Alright thanks let me look at it now
<havenwood>
canteena: Not it isn't psudocode. You can paste it in irb or pry and it's a Hash.
<havenwood>
Note*
lexruee has joined #ruby
<havenwood>
If you can give us a desired output value like that it'll be easy to help you.
<havenwood>
canteena: I'm assuming that's not the return value you want, given `sticks` and `packs`. But that's what we're after. The return value you want.
naitian has quit [Ping timeout: 246 seconds]
canteen4 has joined #ruby
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
naitian has joined #ruby
vondruch has quit [Quit: vondruch]
enterprisey has joined #ruby
vondruch has joined #ruby
canteena has quit [Ping timeout: 248 seconds]
<havenwood>
canteena: A solution given that desired result would be: sticks.each_with_object({}) { |(position, brand), result| result[position] = packs.find { |pack| pack['brand'] == brand } } #=> {"first"=>{"brand"=>"malboro", "type"=>"light"}, "second"=>{"brand"=>"kent", "type"=>"menthol"}}
<canteen4>
ok
enterprisey has quit [Read error: Connection reset by peer]
<canteen4>
Thanks havenwood, I haven't tried this before
chouhoulis has joined #ruby
<havenwood>
canteen4: I'd say think about what return value you really want, then ask again. There are many solutions and folk here can help you find a good one.
<havenwood>
canteen4: I'd suggest looking carefully at the documentation for the Array and Hash classes and the Enumerable module that they both mixin.