<ljarvis>
>> uri = URI("example.com?existing=param"); a = URI.decode_www_form(uri.query); a << ["some", "thing"]; uri.query = URI.encode_www_form(a); puts uri
<ljarvis>
>> require 'uri'; uri = URI("example.com?existing=param"); a = URI.decode_www_form(uri.query); a << ["some", "thing"]; uri.query = URI.encode_www_form(a); puts uri
<sonvu_ae>
I'm confuse that why ruby know |wordaa| in string variable
<olance>
what do you mean, "in string variable" ?
marr has joined #ruby-lang
<sonvu_ae>
I mean i just created a block and put wordaa as parameter and ruby automatic know how to get value from it
<olance>
oh
<olance>
nope :)
<olance>
you've called each on your variable
<sonvu_ae>
olance: string is count_words method parameter
<olance>
each is an iterator, it will call the block you've given it with each character of the string
<sonvu_ae>
so ruby automatic know wordaa when i call each?
Atttwww has quit [Ping timeout: 245 seconds]
<sonvu_ae>
oh i just get it
<olance>
you could see your block do |wordaa| ... end as a function
bin7me has joined #ruby-lang
<olance>
do you know javascript?
<sonvu_ae>
it mean each method of string.each will return every word in "string"?
<sonvu_ae>
yes i see, i'm come from java :)
<olance>
ok
<olance>
not sure you get this in Java though, but this is really like an anonymous function in javascript
<olance>
your block is an argument to the each method
<sonvu_ae>
so each method will return every word in "string"
<sonvu_ae>
and put that into |wordaa|?
<olance>
the each method will call your block repeatedly, once for each word of your string
<olance>
yes :)
<olance>
well in wordaa
tenderlove has joined #ruby-lang
<sonvu_ae>
well its now clearly
<olance>
the pipes | are just the syntax in Ruby to enclose block arguments
<ljarvis>
btw "string" isn't a string
<sonvu_ae>
ruby syntax more lightly than Java
<olance>
ah indeed it's an Array
<sonvu_ae>
i know "string" is an array
<olance>
I had missed that ^^
knu has joined #ruby-lang
<ljarvis>
ok, at least you named it appropriately
<sonvu_ae>
yep now i just get it
kek has quit [Remote host closed the connection]
<sonvu_ae>
this block things is hard to get it
<sonvu_ae>
thanks olance :)
<olance>
:)
<olance>
you're welcome!
<olance>
blocks are hard yes, but very useful ;)
tenderlove has quit [Ping timeout: 260 seconds]
yfeldblu_ has quit [Remote host closed the connection]
yfeldblum has joined #ruby-lang
yfeldblum has quit [Ping timeout: 240 seconds]
stamina has joined #ruby-lang
<olance>
ljarvis: encode_www_form can take a hash as an argument, so it's probably better to use decode_www_form(uri.query).to_h so that existing params can easily be overriden :)
kek has joined #ruby-lang
kek has quit [Remote host closed the connection]
kek has joined #ruby-lang
<sonvu_ae>
olance: can you explain array[][] is what?
<sonvu_ae>
i already know that array[x] is for access value from x position in array
<sonvu_ae>
but array[x][y]
<workmad3>
sonvu_ae: it's exactly the same
<workmad3>
sonvu_ae: but requires array[x] to be holding another array (or something else you can access with [])
<sonvu_ae>
like 2 dimension array?
Miphix has quit [Quit: Leaving]
woollyams has joined #ruby-lang
x0f has quit [Ping timeout: 240 seconds]
<workmad3>
sonvu_ae: ruby doesn't have native n-dimensional arrays... but an array of arrays is a close enough approximation for most people yes :)
<olance>
sorry sonvu_ae I was away
x0f has joined #ruby-lang
<olance>
but workmad3 got it :P
<sonvu_ae>
yes thanks workmad3 and olance
<sonvu_ae>
i move from Java so though Ruby have dimension array
<sonvu_ae>
and do you have good book recommend for start learning ruby
<workmad3>
sonvu_ae: it returns an array of arrays anyway
<sonvu_ae>
yes i got it :)
faces has quit [Ping timeout: 245 seconds]
<workmad3>
sonvu_ae: if you ever end up using a language that does have proper n-dimensional arrays, it's useful to keep the concept separate from an array of arrays ;)
<sonvu_ae>
i did research but it only return the result with sort-by {|a| a}
face has joined #ruby-lang
<sonvu_ae>
not sort_by {|k,v| k}
<sonvu_ae>
thanks workmad
<sonvu_ae>
better keep it different with Java
FiXato has joined #ruby-lang
vintik has quit [Remote host closed the connection]
olance has quit [Ping timeout: 246 seconds]
postmodern has quit [Quit: Leaving]
vintik has joined #ruby-lang
<sonvu_ae>
what is the different if i wrote { 1 => ‘foo’, 2 => ‘bar’ }.sort_by { |k, v| v } instead of { 1 => ‘foo’, 2 => ‘bar’ }.sort_by { |k, v| k }?
<ledestin>
sonvu_ae: the way you want it sorted
vintik has quit [Remote host closed the connection]
<ledestin>
sonvu_ae: try executing it
kwd_ has joined #ruby-lang
kwd has quit [Read error: Connection reset by peer]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
spastorino has joined #ruby-lang
WilfredTheGreat has joined #ruby-lang
<sonvu_ae>
ok executed :)
<sonvu_ae>
sort_by { |k, v| v } will "sort by value" right?
<sonvu_ae>
searched on ruby-doc but they didnt explain this case
<ledestin>
sonvu_ae: well, docs explain that it sorts by whatever block returns
<workmad3>
mark06: ok... and how is that better than OptParser? or trollop? or thor? :)
<sonvu_ae>
can u explain sort_by { |k, v| v } sorted by using <=> on what?
<workmad3>
sonvu_ae: effectively, sort_by will create a new collection by calling that block on each item and recording the returned value
<workmad3>
sonvu_ae: and will then sort using those values
<workmad3>
sonvu_ae: <=> is just an operator in ruby that is semantically good for sorting (as it's meant to return -1 for less than, 0 for equal and 1 for greater than)
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
solars has quit [Ping timeout: 240 seconds]
<mark06>
workmad3: it is explained in the readme file :P but one of the main advantages is that you need *one line* and everything is parsed into $options hash and $arguments array
<workmad3>
mark06: one line and a large comment section
<sonvu_ae>
after your answear and doing another research now i can understand ruby blocks and sort_by things :)
<workmad3>
mark06: as opposed to one line and a block of configuration, etc...
robmiller has quit [Quit: Leaving.]
<workmad3>
mark06: also, you don't support a fairly common argument pattern... '-o SOMEVALUE'
<workmad3>
mark06: and no gem version ;)
robmiller has joined #ruby-lang
ldnunes has joined #ruby-lang
yalue has joined #ruby-lang
Cakey has joined #ruby-lang
banister has joined #ruby-lang
<mark06>
it's an initial version workmad3, there are many ideas we can implement and that's certainly one.....
solars has joined #ruby-lang
tenderlove has joined #ruby-lang
banister has quit [Client Quit]
<mark06>
about large comment section, that's your help text, you'd write at best the same lines with unreadable code... ruby logic mixed with formatting logic.... that's solved by just allowing you to freely format your help text as you desire...
mconnolly has quit [Ping timeout: 256 seconds]
thmzlt has joined #ruby-lang
TvL2386 has joined #ruby-lang
<ledestin>
mark06: I find that option + block is easier to understand
<mark06>
the double-hash doc is three things at the same time... 1) your --help (you don't define an option in one place then write the help in another, you define the option only once)
<mark06>
2) your script documentation (you don't put copyright/license/version in comments, then in --help, then in variables.... you write it only once)
tenderlove has quit [Ping timeout: 264 seconds]
<mark06>
3) the option definition itself.... then just require easyoptions and it's done... no blocks, api calls, option specs needed....
<mark06>
for sure there are fields for improvements though... for example I miss an automated --version, and as you said workmad3, -o VALUE style....
<mark06>
and also I miss macros beyond @script.name... e.g. @script.version (in case you need to store it in a variable, then it reads that var and you don't have to update version in more than one place...)
<workmad3>
mark06: sure, I guess it's suitable for very simple options parsing needs... but I wouldn't say it was much easier than using optparse personally (which also generates the help strings for you when you define the option, keeps it all in one place, etc.)
<workmad3>
mark06: and if you want to add in things like being able to specify whether something should be typecast or not, you'll likely end up with some much harder to read constructs
Cakey has quit [Ping timeout: 240 seconds]
stamina has quit [Remote host closed the connection]
<workmad3>
mark06: also... what happens if I wanted to pass in filenames using your option parser that looked like '0000022212'? ;)
stamina has joined #ruby-lang
<mark06>
hmm no easyoptions won't generate help strings like optparse..... you will, by writing that comment, that *is* your help string..... easyoptions actually does the opposite.... it takes your help text and creates the option spec from there
<mark06>
i.e. it knows what options your program can handle by reading your --help :P
Cakey has joined #ruby-lang
vintik has joined #ruby-lang
<mark06>
I'd like to add type-aware options, yes.... but not with configuration mixed with that help text or any sort... it actually can handle integer at the moment, iirc.... if you pass a number it is automatically parsed into integer....otherwise as string.... and non-value options are booleans....
<mark06>
I'd like to add lists, e.g. "--line-break=windows|unix|mac"
<mark06>
ah yeah the filename would turn into an integer :)
vintik has quit [Ping timeout: 240 seconds]
<workmad3>
mark06: yeah... and my point with optparse is that optparse will construct your help message from your options, while easyoptions will deconstruct your options from your help message... either way, you're writing pretty much the same information ;)
<workmad3>
mark06: i.e. an automatic help message isn't really a differentiating feature (which is kinda what you claimed ;) )
solars has quit [Ping timeout: 240 seconds]
<mark06>
I imagined something simple like a prefix before the value string, e.g. --output=FILE (string even if passing number), but if it's --output=N:NUMBER or --output=number:NUMBER (or whatever syntax we come up wtih) then it should be easy to fix your filename case while making the help text still readable....
<mark06>
or maybe we could use a small database of keywords for guessing the type.... so FILE, FILENAME, PATH and such would always be string, and COUNT, NUMBER etc.... that would be number....
weems|mac has joined #ruby-lang
solars has joined #ruby-lang
<mark06>
there's a very similar project called docopt too
<mark06>
I personally don't like that style because the code isn't as readable as the formatted help and you are limited to the format chosen by the underlying tool....
<centrx>
foucist, I thought _ was just the plainest possible variable name, such as for discarding one result
bantic has quit [Quit: bantic]
mnngfltg has quit [Quit: Ex-Chat]
yfeldblum has joined #ruby-lang
heftig has joined #ruby-lang
MikaAK has joined #ruby-lang
mikecmpbll has quit [Ping timeout: 272 seconds]
theharshest has joined #ruby-lang
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
skade_ has joined #ruby-lang
theharshest has quit [Read error: Connection reset by peer]
bin7me has quit [Remote host closed the connection]
yfeldblum has quit [Ping timeout: 255 seconds]
skade has quit [Ping timeout: 255 seconds]
theharshest has joined #ruby-lang
mehlah has quit [Quit: Leaving...]
MikaAK1 has joined #ruby-lang
MikaAK1 has quit [Client Quit]
mistym has quit [Remote host closed the connection]
sferik has joined #ruby-lang
theharshest has quit [Read error: Connection reset by peer]
theharshest has joined #ruby-lang
<foucist>
centrx: yeah
<foucist>
centrx: irb _ returns last result
<centrx>
crazy b
theharshest has quit [Read error: Connection reset by peer]
theharshest has joined #ruby-lang
Sirupsen has quit [Ping timeout: 245 seconds]
theharshest has quit [Read error: Connection reset by peer]
theharshest has joined #ruby-lang
ironhide_604 has quit [Ping timeout: 240 seconds]
naterubin has left #ruby-lang ["Leaving"]
tbuehlmann has quit [Remote host closed the connection]
theharshest has quit [Read error: Connection reset by peer]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
theharshest has joined #ruby-lang
centrx has quit [Ping timeout: 255 seconds]
sferik has joined #ruby-lang
theharshest has quit [Read error: Connection reset by peer]
theharshest has joined #ruby-lang
relix has joined #ruby-lang
pixelhandler has joined #ruby-lang
kek_ has joined #ruby-lang
kek has quit [Read error: Connection reset by peer]
havenwood has quit [Remote host closed the connection]
WilfredTheGreat has quit [Read error: Connection reset by peer]
havenwood has joined #ruby-lang
mbj has joined #ruby-lang
pr0ton has joined #ruby-lang
RobertBirnie has joined #ruby-lang
kek_ has quit [Remote host closed the connection]
kek has joined #ruby-lang
pr0ton has quit [Client Quit]
dda has quit [Ping timeout: 245 seconds]
wallerdev has joined #ruby-lang
pr0ton has joined #ruby-lang
<ljarvis>
maloik: LOL I just saw your PM from like a month ago :/ sorry
ecnalyr has quit [Quit: Macbook has gone to sleep. . .]
kek has quit [Ping timeout: 240 seconds]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pr0ton has quit [Client Quit]
centrx has joined #ruby-lang
pr0ton has joined #ruby-lang
MikaAK has quit [Quit: node-irc says goodbye]
MikaAK1 has joined #ruby-lang
sferik has joined #ruby-lang
charliesome has joined #ruby-lang
MikaAK2 has joined #ruby-lang
pr0ton has quit [Client Quit]
MikaAK2 has quit [Client Quit]
MikaAK1 has quit [Client Quit]
dsferreira has joined #ruby-lang
seanosaur has quit [Remote host closed the connection]
kiddorails has quit [Remote host closed the connection]
stamina has joined #ruby-lang
Jam has joined #ruby-lang
WilfredTheGreat has joined #ruby-lang
pr0ton has joined #ruby-lang
Jam is now known as Guest48202
mykoweb has quit [Remote host closed the connection]
io_syl has joined #ruby-lang
kiddorails has joined #ruby-lang
benlovell has quit [Ping timeout: 245 seconds]
wallerdev has quit [Quit: wallerdev]
ponch has joined #ruby-lang
pr0ton has quit [Client Quit]
hahuang61 has joined #ruby-lang
<ponch>
Hey y'all i need some help if any of y'all have a have a second
kiddorails has quit [Remote host closed the connection]
<ponch>
i'm trying to download a file from amazon s3 with my app and im getting a 403 forbidden error
<ponch>
i'm using the open("#{link}
<ponch>
send_data method
jaimef has quit [Excess Flood]
jaimef has joined #ruby-lang
<ponch>
anyone on ?
<centrx>
ponch, I am not sure about #send_data, try getting it to work without that component?
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpbll has joined #ruby-lang
<ponch>
centrx, the send_data is the portion that actually sends the download to the computer for download
djbkd has joined #ruby-lang
snsei has quit [Remote host closed the connection]
<centrx>
ponch, Try #rubyonrails for that
jeffs has quit [Ping timeout: 240 seconds]
<ponch>
ah alright sorry i'm am i on the wrong irc?
pr0ton has joined #ruby-lang
mykoweb has joined #ruby-lang
hahuang61 has quit [Ping timeout: 264 seconds]
Atttwww has joined #ruby-lang
<centrx>
ponch, This is a fine channel, you'll just find more people familiar with Rails on #rubyonrails
<centrx>
ponch, #send_data looks like a Rails method, part of ActionController
<centrx>
ponch, The recommendation I was making before was to do a minimal reproduction of the error. Does open(link) work by itself, without the forbidden message?
stamina has quit [Ping timeout: 240 seconds]
<ponch>
well now i'm more confused than i was bc the file downloaded without me seeing at like 11:25 so at one point it worked but its thown an error each time
sferik has joined #ruby-lang
<ponch>
checking right now
<ponch>
no it doesn't it gives the 403
monees has joined #ruby-lang
<ponch>
@centrx i think that might be the trouble line -- the thing that has me confused is that this exact code has worked in the past
cntrx has joined #ruby-lang
<monees>
@ponch
centrx is now known as Guest37535
<ponch>
yes @monees
yfeldblum has joined #ruby-lang
cntrx is now known as centrx
Guest37535 has quit [Ping timeout: 256 seconds]
mistym has joined #ruby-lang
foucist has left #ruby-lang [#ruby-lang]
mbj has quit [Quit: leaving]
mistym has quit [Remote host closed the connection]
apeiros has joined #ruby-lang
wallerdev has joined #ruby-lang
mistym has joined #ruby-lang
yfeldblum has quit [Ping timeout: 264 seconds]
jeffs has joined #ruby-lang
mconnolly has joined #ruby-lang
jbardin has joined #ruby-lang
sferik has quit [Read error: Connection reset by peer]
saarinen has joined #ruby-lang
apeiros has quit [Ping timeout: 240 seconds]
vintik has joined #ruby-lang
robmiller has quit [Quit: Leaving.]
lsegal has joined #ruby-lang
monees has quit [Ping timeout: 240 seconds]
ponch has quit [Ping timeout: 246 seconds]
djbkd has quit [Remote host closed the connection]
mykoweb has quit [Remote host closed the connection]
apeiros has joined #ruby-lang
djbkd has joined #ruby-lang
touzin1 has quit [Ping timeout: 256 seconds]
mbj has joined #ruby-lang
mbj has quit [Client Quit]
francisfish has quit [Remote host closed the connection]
elia has quit [Quit: Computer has gone to sleep.]
pr0ton has quit [Quit: pr0ton]
AncientAmateur has quit [Remote host closed the connection]
kek has joined #ruby-lang
hahuang61 has joined #ruby-lang
heftig has quit [Quit: Quitting]
dangerou_ has quit [Read error: Connection reset by peer]
dangerousdave has joined #ruby-lang
loincloth has quit [Remote host closed the connection]
error404_ has joined #ruby-lang
nirix_ has joined #ruby-lang
achiu1 has joined #ruby-lang
Xney2 has joined #ruby-lang
matled- has joined #ruby-lang
davidae_ has joined #ruby-lang
stamina has joined #ruby-lang
sluukkonen1 has joined #ruby-lang
skade_ has quit [Ping timeout: 240 seconds]
apeiros_ has joined #ruby-lang
lucas_ has joined #ruby-lang
Sigma00_ has joined #ruby-lang
apeiros_ has quit [Remote host closed the connection]
skade has joined #ruby-lang
heftig has joined #ruby-lang
pr0ton has joined #ruby-lang
darix- has joined #ruby-lang
anekos_ has joined #ruby-lang
bantic has joined #ruby-lang
kirin` has quit [Disconnected by services]
Rylee_ has joined #ruby-lang
cntrx has joined #ruby-lang
kirin` has joined #ruby-lang
centrx has quit [Disconnected by services]
Sigma00 has quit [Disconnected by services]
Sigma00_ is now known as Sigma00
Jeticus has joined #ruby-lang
pabs_ has joined #ruby-lang
cntrx is now known as centrx
shaman42_ has joined #ruby-lang
apeiros has quit [*.net *.split]
mistym has quit [*.net *.split]
CaptainJet has quit [*.net *.split]
ledestin has quit [*.net *.split]
Rylee has quit [*.net *.split]
darix has quit [*.net *.split]
error404 has quit [*.net *.split]
araujo has quit [*.net *.split]
shaman42 has quit [*.net *.split]
yugui_zzz has quit [*.net *.split]
_rgn has quit [*.net *.split]
yeltzooo has quit [*.net *.split]
lucas has quit [*.net *.split]
sluukkonen has quit [*.net *.split]
nirix has quit [*.net *.split]
pabs has quit [*.net *.split]
Caius has quit [*.net *.split]
matled has quit [*.net *.split]
Xney has quit [*.net *.split]
jacky has quit [*.net *.split]
yxhuvvd has quit [*.net *.split]
achiu has quit [*.net *.split]
davidae has quit [*.net *.split]
anekos has quit [*.net *.split]
matled- is now known as matled
nirix_ is now known as nirix
mistym_ has joined #ruby-lang
darix- is now known as darix
Xney2 is now known as Xney
kek has quit [Ping timeout: 240 seconds]
ledestin has joined #ruby-lang
jackyalcine has joined #ruby-lang
yeltzooo has joined #ruby-lang
araujo has joined #ruby-lang
stamina has quit [Ping timeout: 240 seconds]
heftig has quit [Quit: Quitting]
yfeldblum has joined #ruby-lang
djbkd has quit [Quit: My people need me...]
yxhuvvd has joined #ruby-lang
yxhuvvd is now known as yxhuvud
djbkd has joined #ruby-lang
heftig has joined #ruby-lang
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Olipro has quit [*.net *.split]
seanosaur has joined #ruby-lang
sarkyniin has quit [Quit: Quitte]
sarkyniin has joined #ruby-lang
symm- has quit [Ping timeout: 245 seconds]
<jeffs>
exit
<jeffs>
\quit
jeffs has quit [Quit: Lost terminal]
ruby-lang477 has joined #ruby-lang
<ruby-lang477>
Hello all, anyone have any exerience trying to get devise and openldap working?
<ruby-lang477>
I am having issues with authentication and I am just stumpped.
apeiros has joined #ruby-lang
<centrx>
ruby-lang477, Try #rubyonrails
<centrx>
ruby-lang477, You will need to register a nickname with Freenode to join that channel
seanosaur has quit [Remote host closed the connection]
seanosaur has joined #ruby-lang
arBmind has joined #ruby-lang
sweo has joined #ruby-lang
Olipro has joined #ruby-lang
ruby-lang477 has quit [Quit: Page closed]
Olipro has quit [Max SendQ exceeded]
monees has joined #ruby-lang
seanosaur has quit [Remote host closed the connection]
skade has quit [Quit: Computer has gone to sleep.]
bantic_ has joined #ruby-lang
bantic has quit [Ping timeout: 256 seconds]
bantic_ is now known as bantic
charliesome has joined #ruby-lang
rushed has quit [Quit: rushed]
seanosaur has joined #ruby-lang
_rgn has joined #ruby-lang
skade has joined #ruby-lang
loincloth has joined #ruby-lang
yugui_zzz has joined #ruby-lang
yugui_zzz has quit [*.net *.split]
skade_ has joined #ruby-lang
centrx has quit [Ping timeout: 240 seconds]
dangerousdave has quit [Read error: Connection reset by peer]
dangerousdave has joined #ruby-lang
rushed has joined #ruby-lang
skade has quit [Ping timeout: 240 seconds]
heftig has quit [Quit: Quitting]
Olipro has joined #ruby-lang
thmzlt has quit [Remote host closed the connection]
Olipro has quit [Max SendQ exceeded]
heftig has joined #ruby-lang
thmzlt has joined #ruby-lang
thmzlt has quit [Remote host closed the connection]
bruno- has quit [Ping timeout: 240 seconds]
thmzlt has joined #ruby-lang
yugui_zzz has joined #ruby-lang
bruno- has joined #ruby-lang
piezol has quit [Ping timeout: 246 seconds]
thmzlt has quit [Ping timeout: 256 seconds]
djbkd has quit [Remote host closed the connection]
superfreenodeman has joined #ruby-lang
superduperfreeno has joined #ruby-lang
superduperfreeno has quit [Client Quit]
sweo has quit [Remote host closed the connection]
centrx has joined #ruby-lang
stamina has joined #ruby-lang
symm- has joined #ruby-lang
bantic has quit [Quit: bantic]
Olipro has joined #ruby-lang
Olipro has quit [Max SendQ exceeded]
sweo has joined #ruby-lang
karamazov has joined #ruby-lang
Olipro has joined #ruby-lang
vintik has quit [Remote host closed the connection]
rahul_j has quit [Ping timeout: 264 seconds]
sepp2k has joined #ruby-lang
rahul_j has joined #ruby-lang
touzin1 has joined #ruby-lang
superfreenodeman has quit [Ping timeout: 264 seconds]
hahuang61 has quit [Ping timeout: 256 seconds]
vintik has joined #ruby-lang
sweo has quit [Remote host closed the connection]
earthquake has joined #ruby-lang
elia has joined #ruby-lang
tejas-manohar has joined #ruby-lang
<tejas-manohar>
yo anyone checked out the new gmail api with ruby?
<tejas-manohar>
the method im writing takes in sender's email, recipent's, subject and body
hotpancakes has quit [Ping timeout: 252 seconds]
mconnolly has quit [Quit: mconnolly]
MikaAK has joined #ruby-lang
jsullivandigs has quit [Remote host closed the connection]
lolmaus has joined #ruby-lang
hotpancakes has joined #ruby-lang
jbardin has joined #ruby-lang
lolmaus has quit [Read error: Connection reset by peer]
loincloth has quit [Remote host closed the connection]
dsferreira has quit [Quit: This computer has gone to sleep]
lolmaus has joined #ruby-lang
elia has quit [Quit: Computer has gone to sleep.]
<karamazov>
I'm dealing with some JSON which serves me an array of hashes. I've selected the specific has I want and it is currently [{"name" => "foo", "desc" => "bar:}] How can I remove it from the array?
<karamazov>
*selected the specific array
<apeiros>
ary.delete
BucOder_ has quit [Quit: Computer has gone to sleep.]
<karamazov>
apeiros: Would that be better than be just referencing the array as response[0]?
jsullivandigs has joined #ruby-lang
<karamazov>
*me
<apeiros>
karamazov: you didn't mention with one word why you want to delete the hash from the array. how do you suppose I deduce your use case and decide what solution is best?
loincloth has joined #ruby-lang
<karamazov>
Bad wording, apologies
<apeiros>
delete is more expensive than referencing. with the given information, there's not much more I could say.
MikaAK1 has joined #ruby-lang
postmodern has quit [Quit: Leaving]
<karamazov>
apeiros: I'm new to JSON but I receive and array full of hashes, I then filter that array down to a single hash -> [{"name" => "foo", "desc" => "bar:}] but when I want to set parameters I can only submit a hash. Wasn't sure if there was a more eloquent way of turning it into a hash besides referencing it.
<karamazov>
Man...spelling today *receive an array
Squarepy has joined #ruby-lang
elia has joined #ruby-lang
ldnunes has quit [Quit: Leaving]
<apeiros>
hash = ary.first
<apeiros>
but maybe you can use a more eloquent way of filtering
<apeiros>
which yields a single hash to start with, instead of an array
<jxport>
Ack, I think I should have asked my question here..
<karamazov>
I populate a select field with all the repo names, the user selects one, then I filter that out of the collection to yield one hash within the array
<apeiros>
karamazov: use .find instead of .select
<jxport>
When is it appropriate to use keyword arguments?
kyb3r_ has quit [Read error: Connection reset by peer]
<karamazov>
apeiros: I'll give it a try real quick, thanks
<ledestin>
jxport: when your audience wouldn’t mind using it
<karamazov>
apeiros: Perfect...thank you!
<jxport>
ledestin: I like the idea of not necessitating parameter ordering - I'm concerned I might overuse it, though (is that possible?)
<ledestin>
jxport: it’s a replacement of {} at the end
<jxport>
ledestin: my thought is - why not use it whenever there are 3+ parameters?
<jxport>
And then - why not even just 2+?
<karamazov>
I missed the part in the ruby-doc where select says it returns an array :)
<ledestin>
jxport: that’s a good idea IMHO
<ledestin>
jxport: consider switch(true/false), a contrived example. you could use a keyword argument, or better, 2 methods
<ledestin>
jxport: turn_on and turn_offf
<jxport>
ledestin: what about methods that only have two parameters? Would that be excessive?
<karamazov>
apeiros: Can you explain the closing of handles? I'm not finding much on google
<ledestin>
jxport: I follow readability, if it’s readable it’s good
<jxport>
ledestin: it can just get very duplicative quickly