Possible Duplicate:
Merging deep hash in ruby
So I have a hash with the following structure (exploded out to YAML for viewing), that I want to merge/consolidate/flatten down by the very first key.
- 1001:
Twitter:
values:
"2012-11-29": 24.0
- 1001:
Linkedin:
values:
"2012-11-29": 25.0
- 1001:
Facebook:
values:
"2012-11-29": 6.0
- 2002:
Twitter:
values:
"2012-11-29": 26.0
- 2002:
Pinterest:
values:
"2012-11-29": 1.0
That I want to get it down to the following form as easily as possible:
- 1001
Twitter:
values:
#some values here
Facebook:
values:
#some values
- 2002
Pinterest:
values:
Facebook:
values:
I've tried zipping, merging, splating the Hashes every way I know how, but the best I can get is a new Hash that discards all but the first 2nd-level value it finds.
Any ideas?