This seems like it should be fairly simple, but for some reason I can't think of the right way to do this:
I have a string h
that looks something like one(two(three four) five six) seven
.
I'd like to split this up into an array of hashes so that the output is something like
{'one' =>
{'two' =>
{'three' => nil, 'four' => nil},
'five'=>nil, 'six'=>nil
}, 'seven'=>nil}
We can assume that there are equal numbers of parenthesis.
Is there any easy way to do this? In a language that encourages use of for looks, this would be relatively simple; I don't think I've been using Ruby long enough to get a feel for the Ruby way of doing this sort of problem.
Thanks!