<jsilver>
say I have an array of hashes, with id keys in it, and I have another string "id, id, id, id". how do I sort the array of hashes by that list of ids?
KramerC has quit [Ping timeout: 240 seconds]
coyo has quit [Ping timeout: 240 seconds]
oliv_____ has joined #ruby
erlend has joined #ruby
DarkBushido has joined #ruby
DarkBushido has joined #ruby
DarkBushido has quit [Changing host]
bandu has joined #ruby
<matthewd>
jsilver: What do you have so far?
Apocalypse has joined #ruby
segy has joined #ruby
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lele has joined #ruby
<jsilver>
i have something which calls an api and says gives me ids 1...x and then it returns them out of order
KramerC has joined #ruby
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
govg has quit [Ping timeout: 268 seconds]
GodFather has joined #ruby
Chch has quit [Ping timeout: 260 seconds]
lmc has quit [Remote host closed the connection]
nobitanobi has joined #ruby
jsilver has quit [Quit: Page closed]
lmc has joined #ruby
jeyraof^mbpr has joined #ruby
jeyraof^mbpr has quit [Client Quit]
nobitanobi has quit [Ping timeout: 240 seconds]
patarr_ has quit [Ping timeout: 264 seconds]
ekinmur has joined #ruby
lmc has quit [Ping timeout: 268 seconds]
dviola has quit [Quit: WeeChat 1.7]
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
milardovich has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
grrrkit has quit [Ping timeout: 264 seconds]
<allisio>
Verity: Congratulations on "getting there", for some definition of the term.
<allisio>
Be advised that #map uses the result of the block for the transformation, so that assignment to `char` is perfectly superfluous.
nobitanobi has joined #ruby
Yzguy has quit [Quit: Zzz...]
aglorei has quit [Remote host closed the connection]
aglorei1 has joined #ruby
xnxq has quit [Ping timeout: 264 seconds]
certainty has joined #ruby
hahuang61 has joined #ruby
nobitanobi has quit [Ping timeout: 240 seconds]
certainty has quit [Ping timeout: 260 seconds]
tolerablyjake has joined #ruby
mzo has joined #ruby
d^sh has quit [Ping timeout: 246 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
d^sh has joined #ruby
Pumukel has joined #ruby
libastral has quit [Ping timeout: 246 seconds]
libastral has joined #ruby
bmurt has joined #ruby
bmurt has quit [Client Quit]
Yzguy has joined #ruby
astrobunny has quit [Remote host closed the connection]
astrobunny has joined #ruby
astrobunny has quit [Ping timeout: 246 seconds]
enterprisey has quit [Ping timeout: 240 seconds]
whiteline has joined #ruby
raspado has joined #ruby
Chch has joined #ruby
milardovich has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
astrobunny has joined #ruby
jeyraof^mbpr has joined #ruby
MrJoshua has joined #ruby
raspado has quit [Remote host closed the connection]
raspado has joined #ruby
milardovich has quit [Read error: Connection reset by peer]
milardovich has joined #ruby
<Verity>
aha, ty
Yzguy has quit [Quit: Zzz...]
br0d1n has quit [Quit: Leaving]
JeanCarloMachado has quit [Ping timeout: 268 seconds]
Pumukel has quit [Ping timeout: 260 seconds]
HoierM has quit [Ping timeout: 260 seconds]
centrx has quit []
s2013 has joined #ruby
sylario has quit [Quit: Connection closed for inactivity]
tolerablyjake has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest96_ has joined #ruby
Guest96 has quit [Ping timeout: 240 seconds]
raspado has quit [Remote host closed the connection]
raspado has joined #ruby
marcdel has joined #ruby
astrobunny has quit [Remote host closed the connection]
bkxd has joined #ruby
<Disavowed>
allisio: Are you trying to write Ruby in Python again? :P
<allisio>
Disavowed: Just digging.
<Disavowed>
Don't leave here
jameser has joined #ruby
bkxd has quit [Ping timeout: 260 seconds]
roamingdog has quit []
JoshS has quit [Ping timeout: 260 seconds]
davorb has quit [Read error: Connection reset by peer]
davorb has joined #ruby
allisio has quit [Ping timeout: 240 seconds]
rakm has joined #ruby
mzo has quit [Quit: :*]
gnufied has joined #ruby
gix has quit [Ping timeout: 240 seconds]
<baweaver>
Disavowed: I was just reminding them they have a REPL in their CLI.
allisio has joined #ruby
<baweaver>
I'll let someone know if it's really a problem
Chch has quit [Quit: Leaving]
astrobunny has joined #ruby
gix has joined #ruby
JoshS has joined #ruby
<Disavowed>
baweaver: I think it was a bit of a mischaracterisation to say you yelled, too. Speaking of repls, does anyone have any preferable alternatives to pry?
<baweaver>
Pry not working?
<Disavowed>
No it's fine. Just wanted to make sure I wasn't missing out on anything
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Radar>
pry4lyfe
Autolycus has joined #ruby
shinnya has quit [Ping timeout: 256 seconds]
hahuang65 has quit [Quit: WeeChat 1.7]
<allisio>
^
<Disavowed>
Just saw the plugins page. Perhaps I could soup it up a little
hahuang61 has quit [Ping timeout: 246 seconds]
BabyMario has joined #ruby
cyphase has joined #ruby
NightMonkey has quit [Ping timeout: 240 seconds]
gnufied has quit [Ping timeout: 246 seconds]
hahuang61 has joined #ruby
NightMonkey has joined #ruby
lmc has joined #ruby
hahuang61 has quit [Ping timeout: 264 seconds]
tau has quit [Remote host closed the connection]
astrobunny has quit [Remote host closed the connection]
lmc has quit [Ping timeout: 240 seconds]
IRCFrEAK has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
choke has joined #ruby
IRCFrEAK has left #ruby [#ruby]
nickjj_ has quit [Read error: Connection reset by peer]
<herwin>
this is pretty close to what you are trying to do
TomyLobo2 has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
bkxd has joined #ruby
<HippoDippo>
elomatreb: How would you check the array to see if the elements are sorted?
Cohedrin has joined #ruby
Mortomes|Work has joined #ruby
<elomatreb>
Loop through it until you find an element that is larger than the next (assuming you want ascending order), immediately fail if you do. If you reach the end of the array without finding such an element, you're sorted
<HippoDippo>
ahhh ok thanks
<elomatreb>
Tip: Array#each_cons instead of fumbling about with index variables
CloCkWeRX has quit [Ping timeout: 246 seconds]
<HippoDippo>
So those index variables were bad?
cam27 has quit [Quit: cam27]
bkxd has quit [Ping timeout: 240 seconds]
muelleme_ has quit [Ping timeout: 256 seconds]
<elomatreb>
Not *bad*, but it's easy to make a mistake and e.g. accidentally get an element too much (past the end of the array). In other languages this might fail immediately, but in Ruby it silently returns nil
<HippoDippo>
Ohh i see. I was basically trying to make a sort method with the bare essentials
lubekpl has joined #ruby
last_staff has joined #ruby
sjums_ is now known as sjums
gdonald has quit [Read error: Connection reset by peer]
gdonald has joined #ruby
green_hat has joined #ruby
andikr has joined #ruby
HippoDippo has quit [Quit: Going offline, see ya! (www.adiirc.com)]
jenrzzz has quit [Ping timeout: 256 seconds]
hahuang61 has joined #ruby
jusa has joined #ruby
Verity has quit [Ping timeout: 246 seconds]
patarr has joined #ruby
muelleme_ has joined #ruby
BabyMario has quit [Quit: bye]
mark_66 has joined #ruby
doublemalt_ has quit [Ping timeout: 256 seconds]
lmc has joined #ruby
<herwin>
you could start of with a very simple implementation (like "def sort(array); array.sort; end"), write a number of test cases for it, and then just keep changing things to get closer and closer to bare metal
<herwin>
the test cases could be used to see if the implementation still works
nowhere_man has quit [Ping timeout: 260 seconds]
hahuang61 has quit [Ping timeout: 256 seconds]
Verity has joined #ruby
patarr has quit [Ping timeout: 240 seconds]
lmc has quit [Ping timeout: 240 seconds]
Zarthus has quit [Ping timeout: 260 seconds]
dfoolz has quit [Ping timeout: 260 seconds]
dfoolz has joined #ruby
Zarthus has joined #ruby
valentinul has joined #ruby
Arpanet69 has joined #ruby
Kug3lis has joined #ruby
vali has joined #ruby
TomyWork has joined #ruby
pulkit4tech has quit [Quit: Connection closed for inactivity]
davorb has quit [Read error: Connection reset by peer]
davorb has joined #ruby
grillon has quit [Quit: Connection closed for inactivity]
muelleme_ has quit [Ping timeout: 264 seconds]
fmartingr has joined #ruby
green_hat has quit []
govg has joined #ruby
jgnagy has quit [Remote host closed the connection]
pulkit4tech has quit [Quit: Connection closed for inactivity]
<vasilakisfil>
when I dynamically define a new class, it picks up the inheritence not the methods in the block though
jenrzzz has joined #ruby
hutch34 has quit [Ping timeout: 264 seconds]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jusa has joined #ruby
<matthewd>
vasilakisfil: You need to either pass the block directly to Class.new as &block, or use instance_exec
postmodern has quit [Quit: Leaving]
jenrzzz has quit [Ping timeout: 240 seconds]
<matthewd>
vasilakisfil: But that's not an endorsement of the strategy; it looks unwise to me -- unconventional, opaque, class definitions aren't doing future developers any favours
jusa has quit [Ping timeout: 264 seconds]
banisterfiend has quit [Ping timeout: 240 seconds]
Snickers has joined #ruby
fxa90id has quit [Changing host]
fxa90id has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
siovene has quit [Quit: Connection closed for inactivity]
<centrx>
Verity: or (0..7).each do |n| puts n end for multi-line blocks
<Verity>
ty, I see now
shinnya has joined #ruby
TheWhip has joined #ruby
s2013 has joined #ruby
tekku is now known as tekk
igniting has quit [Ping timeout: 246 seconds]
TheWhip_ has joined #ruby
jwsuiw has joined #ruby
lmc has joined #ruby
ta_ has quit [Remote host closed the connection]
bkxd has joined #ruby
TheWhip has quit [Ping timeout: 258 seconds]
blackmesa has quit [Ping timeout: 240 seconds]
ddffg has quit [Ping timeout: 258 seconds]
lmc has quit [Remote host closed the connection]
ldnunes has joined #ruby
<Verity>
Alright, I typed up and fully understood the C++ code. I tried it out a bit and it works. Then I tried to translate it to ruby. I'm close, and have made progress. I'm not there yet. I managed to get rid of all syntax errors, and now my only remaining problem is incorrect crc result.
<canton7>
you can modify gists btw, at least if you're signed into github
Snickers has joined #ruby
lmc has joined #ruby
<canton7>
right, so line 11 is still buggy, and packet[byte].to_i will still return 0 for almost everything
<canton7>
and you're still assuming that 0 is falsy, when ruby treats it as truthy
<matthewd>
canton7: No it won't
<canton7>
matthewd, "1hello0"[1].to_i is 0. What am I missing?
<matthewd>
(though the to_i is now unnecessary)
<canton7>
aaah, .bytes, that's what
<matthewd>
So yeah, flip 11, fix the zero conditionals, and this is sounding right
toretore has joined #ruby
<canton7>
ah, no, not quite
truenito has joined #ruby
blackmesa has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
<canton7>
that 'reg <<= 1' line in the C++ looks odd. It's going to be execute 56 times, but only has 16 bits, so it's going to end up as 0 and stay as 0 fairly quickly
<canton7>
ruby doesn't know that it's only 16 bits wide, and so won't do that - so you'll have a difference there
TomyWork has quit [Ping timeout: 240 seconds]
lmc has quit [Quit: Leaving...]
<canton7>
ah no, I missed the 'reg |= 1', so the C++ is probably OK. Regardless, the ruby won't follow the same behaviour in some cases
zeddan has joined #ruby
<matthewd>
Irrelevant, though it'll mean we have a bignum involved; the final result is masked on 16
thadtheman has quit [Ping timeout: 258 seconds]
<matthewd>
Only the bottom 9 bits of reg are used
<matthewd>
Oh and actually, none of the rest can get set
Guest96_ has quit [Quit: Guest96_]
<matthewd>
poly clears bit 9 any time it gets set, before it can be shifted further
<canton7>
truueee
<Verity>
yes thats how it was supposed to function
<Verity>
from my limited understanding of the algorithm
<Verity>
let me take a look at the remaining errors
Arpanet69 has joined #ruby
<canton7>
also, given it's ruby, you'll probably want to do 'packet.each do |byte| on line 7 (and use 'byte' instead of 'packet[byte].to_i' on line 11)
centrx has quit []
blackmesa has quit [Ping timeout: 260 seconds]
<matthewd>
Yeah, I was waiting until it was working, but +1
<matthewd>
Line 4 can go away
<canton7>
fair, I'm getting ahead of myself
oliv_____ has quit [Remote host closed the connection]
|RicharD| has quit [Quit: Sto andando via]
truenito has quit [Remote host closed the connection]
|RicharD| has joined #ruby
oliv_____ has joined #ruby
DaveTaboola has joined #ruby
nofxx has joined #ruby
bkxd has joined #ruby
<Verity>
thank you canton7 that looks much cleaner
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
bkxd has quit [Ping timeout: 240 seconds]
thadtheman has joined #ruby
blackpajamas has quit [Quit: WeeChat 1.7]
<Verity>
flip 11 do you mean
<Verity>
byte & mask if reg |= 1 >>> if reg |= 1 byte & mask
<Verity>
I thought those were equivalent
psychicist__ has joined #ruby
<matthewd>
Those are equivalent, and neither match what the C++ is doing
<Verity>
ok let me look more closely
<canton7>
the C++ doesn't say 'if reg |= 1 byte & mask' though...
pulkit4tech has joined #ruby
mark_66 has quit [Remote host closed the connection]
<Verity>
ah I see now what you meran
<Verity>
that was a purely amateur mistake =\
eblip has joined #ruby
ekinmur has joined #ruby
<canton7>
(the clue is that the condition shouldn't have side effects (and yours does), while the statement should actually do something (which yours doesn't)
ekinmur_ has quit [Read error: Connection reset by peer]
User458764 has joined #ruby
oliv_____ has quit [Remote host closed the connection]
<herwin>
just keep adding random statements until it compiles?
<Verity>
herwin, yes
<Verity>
thats easier now with the plugins I just got for vscode
<Verity>
shows syntax errors before they happen, but can't help with this sort of semantic problem
jgnagy has joined #ruby
<canton7>
"just keep adding random statements until it compiles" is supposed to be a very bad thing... You're not supposed to go "Yes! That's what I do!" :P
synthroid has quit [Remote host closed the connection]
spicerack has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<baweaver>
if you do something in map you can have a new version of the string
silva has joined #ruby
<baweaver>
though do note this is just ROT13
brent__ has quit [Remote host closed the connection]
<baweaver>
so tr is a much simpler solution.
brent__ has joined #ruby
<himmmmmm>
tr?
<baweaver>
See the above link
jenrzzz has quit [Ping timeout: 260 seconds]
Lord_of_Life has joined #ruby
<silva>
hello, I'm having this error "undefined method `zip' for nil:NilClass" in this code line "latency.zip metric" I'm not a ruby programmer, I just wanna run a probram. What should I do?
swills_ is now known as swills
<canton7>
silva, 'latency' is nil
<matthewd>
silva: Report a bug to whoever wrote the program
<silva>
canton7: so I have to install latency gem?
<canton7>
silva, I've no idea. That specific varilable is nil. I've no idea why that might be, from the information you've given us
Pumukel has quit [Remote host closed the connection]
<himmmmmm>
chr_num = n % rotate
<himmmmmm>
rotate = 13
gdonald has quit [Read error: Connection reset by peer]
Pumukel has joined #ruby
<matthewd>
That doesn't sound like "add" to me
<silva>
baweaver, matthewd: so I have to intsall fpinglocaly
gdonald has joined #ruby
<baweaver>
yeah
<baweaver>
looks like it
<himmmmmm>
chr_num + 65 or chr_num + n
Qchmqs has quit [Ping timeout: 260 seconds]
<matthewd>
And that doesn't sound like 13
<himmmmmm>
but i did the mod to find out where the + 13 should be
<Verity>
me?
<himmmmmm>
i get it i think
<matthewd>
himmmmmm: As I said: throw this away, and start from the actual definition. The only things this has in common with the right answer is that they both have a mod operation and an addition (but not in this order)
Arpanet69 has joined #ruby
<matthewd>
Verity: Yes, my immediate reply was to you. What does your code look like now?
<Verity>
give me a minute, I'm adding it into the maina pplication now
jwsuiw has quit [Remote host closed the connection]
deuterium has quit [Ping timeout: 260 seconds]
thadtheman has joined #ruby
nh` has quit [Remote host closed the connection]
Pumukel has quit [Ping timeout: 246 seconds]
<silva>
thanks guys that was the problem :)
juggler has joined #ruby
jsrn_ has quit [Quit: Leaving]
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
TheWhip_ has quit [Remote host closed the connection]
<baweaver>
Now what if you need to ROT13 some arbitrary string?
kegster has joined #ruby
<matthewd>
It's fun to implement it "manually" as an exercise, but if someone actually tried to commit this instead of using the appropriate built-in function, "it's easier for a non-programmer to read" would not get it past code review
<matthewd>
Verity: Is that because you're now including EOT?
cam27 has left #ruby [#ruby]
<himmmmmm>
can we petition to change the spaceship operator to something that looks more like a spaceship?
<jhass>
adavia: could you add sample input and desired and actual output?
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thadtheman has joined #ruby
knight33 has joined #ruby
knight33 has quit [Client Quit]
xnxq has quit [Ping timeout: 246 seconds]
tomphp has joined #ruby
tercenya has joined #ruby
brent__ has quit [Remote host closed the connection]
brent__ has joined #ruby
ta_ has joined #ruby
SeepingN has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
cdg has quit [Remote host closed the connection]
gloscombe has joined #ruby
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
ta_ has quit [Remote host closed the connection]
thadtheman has quit [Ping timeout: 264 seconds]
last_staff has quit [Quit: last_staff]
elaptics_ has joined #ruby
slackbotgz has quit [Remote host closed the connection]
psychici1t__ has joined #ruby
araujo has quit [Ping timeout: 260 seconds]
meshsmith has joined #ruby
centrx has joined #ruby
psychicist__ has quit [Read error: Connection reset by peer]
sepp2k has joined #ruby
kirun has joined #ruby
muelleme_ has quit [Ping timeout: 264 seconds]
araujo has joined #ruby
silva has quit [Ping timeout: 260 seconds]
cfec0b8d has joined #ruby
ta_ has joined #ruby
millerti has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
TheWhip has quit [Remote host closed the connection]
millerti has joined #ruby
moei has joined #ruby
renchan has joined #ruby
thadtheman has joined #ruby
Renich has joined #ruby
Fernando-Basso has joined #ruby
wkoszek has quit [Remote host closed the connection]
porton has joined #ruby
<porton>
I've read "the first edition of the Pragmatic Programmers’ book". What to read next: Ruby User's Guide or https://en.wikibooks.org/wiki/Ruby_Programming? (I am an advanced programmer but new with Ruby)
<porton>
I need it for Rails
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
esObe_ has quit [Read error: Connection reset by peer]
<Ebok>
Have you Read the Community Guidelines for Ruby? I found it extremely useful when learning the language.
<Ebok>
It's mostly syntax, but due to that it ends up being a great list of features.
THEKKKLAN has joined #ruby
<Ebok>
Which can be easily googleable / testable
<THEKKKLAN>
Hello
ged has joined #ruby
bkxd has quit [Ping timeout: 240 seconds]
mahlon has joined #ruby
ta_ has quit [Quit: Leaving...]
gloscombe has quit [Quit: gloscombe]
<porton>
I see [[Exceptions]] in https://en.wikibooks.org/wiki/Ruby_Programming is 0% developed. So I assume it is a work in progress and I should read Ruby User's Guide instead. Right?
<SeepingN>
thanks for the POODR ref
<THEKKKLAN>
I'm writing a ruby app that educates the ignorant about the dangers of immigrants kikes and niggers
<SeepingN>
just what I need to write real ruby and not this functional garbage
<elomatreb>
!ops
<ruby[bot]>
elomatreb: ops currently in #ruby: adaedra, aredridel, havenwood, Radar, apeiros, baweaver, helpa, jhass, ljarvis, matthewd, miah, ruby[bot] and zzak
davorb has quit [Read error: Connection reset by peer]
<Disavowed>
Poodr looks really good actually. I was trying to work through a Sandy Metz blog post in a similar vein but keep putting it off. Thank you adam12
<adam12>
Disavowed: Sandi's done a bunch of great talks too, on Youtube.
<jhass>
adavia: so you need to either repeat all checks in a single if that adds the nil or keep a boolean to decide at the end whether or not to add the nil
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
tercenya has quit [Remote host closed the connection]
<adavia>
yes
Ebok has quit [Quit: Leaving]
<jhass>
or you make it an if/elsif chain if only ever ony of the keys is present/accepted
<jhass>
*one
<adavia>
I guess i tried that
tercenya has joined #ruby
montanonic has joined #ruby
ionte_ has quit [Ping timeout: 240 seconds]
<jhass>
so what's the desired output for [{answer_open: "foo", answer_image: "bar"}]?
<adavia>
i need to output a new array as ["Foo", nil, "Bar"]
<jhass>
that doesn't seem to answer my question
ionte has joined #ruby
centrx has quit []
tercenya has quit [Remote host closed the connection]
hahuang65 has quit [Ping timeout: 240 seconds]
<adavia>
jhass: in that case ["foo", "bar"]
tercenya has joined #ruby
<jhass>
and [{answer_open: "", answer_image: ""}] ?
<adavia>
[nil, nil]
xnxq has joined #ruby
<jhass>
how about [{answer_open: nil, answer_image: nil}] then?
<adavia>
That should return also [nil, nil]
synthroid has quit []
brent__ has quit [Remote host closed the connection]
renchan has quit [Remote host closed the connection]
<allisio>
hxegon: Naughty, naughty.
<hxegon>
whoops :|
electrostat has quit [Quit: uwotm8]
<hxegon>
sorry adavia, pay no attention to my assetry
xnxq has quit [Ping timeout: 258 seconds]
electrostat has joined #ruby
Rodya_ has quit [Remote host closed the connection]
ResidentBiscuit has joined #ruby
cdg has joined #ruby
<adavia>
jhass: [["foo", nil], [nil, "bar"]]
<jhass>
now that's quite different to all you previous examples
<adavia>
Umm
<jhass>
I couldn't find a clear pattern in your answers and I think that's your main issue. Try to get a clearer understanding on what should transform to what and what the constraints on your input are exactly
<jhass>
for example given the last one, why wouldn't [{answer_open: "foo"}] translate to [["foo"]] or even [["foo", nil]]?
<adavia>
jhass: Still theres no input like [{answer_open: "foo", answer_image: nil}, {answer_open: nil, answer_image: "bar"}]
<jhass>
well then you should've said so as I posed the example ;)
vasilakisfil has quit [Quit: Konversation terminated!]
<adavia>
Yeah sorry i wasnt paying attention
<jhass>
yet enough to come up with some output
brent__ has joined #ruby
<jhass>
the question remains whether [{answer_open: "foo", answer_image: nil}] is valid or different from [{answer_open: "foo"}]
<adavia>
jhass: Thats valid.. in that case i should get ["foo"]
<adavia>
["foo", nil] ["foo"]
gusrub has joined #ruby
gusrub has quit [Remote host closed the connection]
<jhass>
so why'S the first different from the second?
gusrub has joined #ruby
<jhass>
given {}[:answer_open] returns nil
<adavia>
jhass: i want to raplace any blank values with nil
<jhass>
blank in the rails/AS sense or as in String#empty?
<adavia>
jhass: in the rails sense should be present?
brent__ has quit [Remote host closed the connection]
brent__ has joined #ruby
<jhass>
then one could argue that, given nil is blank?/!present? and {}[:foo] returns nil, a non-existent key is as blank as one pointing to the empty string
<jhass>
or nil
pabloh has joined #ruby
bkxd has quit [Ping timeout: 240 seconds]
SeepingN has quit [Ping timeout: 260 seconds]
<jhass>
don't get me wrong, it can be entirely valid to treat a non-existent key differently than one set to nil, I just want to make sure you have a good reason to do so
thadtheman has quit [Ping timeout: 240 seconds]
workmad3 has joined #ruby
<jhass>
especially since your target datastructure seems rather lossy, for example [{answer_open: "foo"}, {answer_image: "bar"}] and [{answer_image: "foo"}, {answer_open: "bar"}] both would convert into the same output
<adavia>
jhass: the real explanation is to export a csv with blank values in case attributes are not present. Otherwise the headers do not match with my rows lol
<jhass>
so what's your headers?
<adavia>
"answer_open", "answer_image" and for those i need "foo" "bar" or nil, "bar" or nil, "bar"
<adavia>
"bar", nil
<jhass>
so it should be an array of two element arrays after all, no?
<adavia>
yes
<jhass>
well none of your examples had that except the last one for the invalid input
yurikoles has quit [Remote host closed the connection]
hxegon has quit [Quit: Lost terminal]
hxegon has joined #ruby
agent_white has quit [Quit: bbl]
kirun has quit [Quit: Konversation terminated!]
milardovich has quit []
DLSteve has quit [Quit: All rise, the honorable DLSteve has left the channel.]
thadtheman has quit [Ping timeout: 240 seconds]
millerti has joined #ruby
kazo has quit [Quit: Page closed]
br0d1n has joined #ruby
thadtheman has joined #ruby
spicerack has joined #ruby
montanonic has quit [Ping timeout: 260 seconds]
daivyk has quit [Quit: Quit]
oncall-pokemon has joined #ruby
Synthead has joined #ruby
workmad3 has quit [Ping timeout: 256 seconds]
thadtheman has quit [Ping timeout: 268 seconds]
patarr has joined #ruby
chouhoul_ has joined #ruby
cpruitt has quit [Quit: cpruitt]
JoshS has quit [Ping timeout: 260 seconds]
choke has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chouhoulis has quit [Ping timeout: 246 seconds]
cpruitt has joined #ruby
chouhoul_ has quit [Ping timeout: 246 seconds]
montanonic has joined #ruby
Verity has quit [Disconnected by services]
Verity has joined #ruby
hutch34_ has quit [Ping timeout: 260 seconds]
<SeepingN>
well damn. It appears that "trap
<Gaelan>
??
<SeepingN>
well damn. It appears that "trap" takes over regardless of scope
cagomez has quit [Remote host closed the connection]
hahuang65 has joined #ruby
<SeepingN>
so if I define an "outter trap" to catch ^C, and a different one while inside a particular function, that upon leaving that block, trap does not "revert"
cagomez has joined #ruby
<SeepingN>
and runs irrelevant code that was defined inside that block/function
thadtheman has joined #ruby
CloCkWeRX has joined #ruby
montanonic has quit [Ping timeout: 268 seconds]
cpruitt has quit [Quit: cpruitt]
jerme_ has joined #ruby
davorb has quit [Read error: Connection reset by peer]
davorb has joined #ruby
Jayson_Virissimo has quit []
pabloh has quit [Quit: Leaving]
bkxd has joined #ruby
sepp2k has quit [Ping timeout: 256 seconds]
jusa has joined #ruby
meshsmith has joined #ruby
patarr has quit [Ping timeout: 240 seconds]
bkxd has quit [Ping timeout: 260 seconds]
jusa has quit [Ping timeout: 260 seconds]
nofxx has quit [Remote host closed the connection]
tvw has quit [Remote host closed the connection]
nofxx has joined #ruby
tau is now known as caboclo-tau
gloscombe has quit [Quit: gloscombe]
AndBobsYourUncle has joined #ruby
AndBobsYourUncle has quit [Client Quit]
Sauvin has quit [Read error: Connection reset by peer]
<cahoots_>
hi, i want to run a shell command, show the output as each line is written to stdout, and only return when the command is done. i've tried Process.spawn("sleep 2; echo 'hi'; sleep 2; echo 'hey'"); Process.wait
<cahoots_>
but that returns immediately
<cahoots_>
any ideas?
<volty>
system?
<cahoots_>
volty, hey nice
<cahoots_>
thx
tolerablyjake has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
CloCkWeRX has quit [Ping timeout: 268 seconds]
grillon has quit [Quit: Connection closed for inactivity]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
t-recx has joined #ruby
charliesome has joined #ruby
cagomez has quit []
patarr has quit [Ping timeout: 240 seconds]
skweek has joined #ruby
patarr has joined #ruby
Gaelan has quit [Quit: Gaelan]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
choke has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Gaelan has joined #ruby
Robtop__ has joined #ruby
CloCkWeRX has joined #ruby
BabyMario has joined #ruby
rakm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]