Created
April 15, 2013 08:49
-
-
Save pkordel/5386788 to your computer and use it in GitHub Desktop.
Recursive parsing challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Should return this: | |
# [ | |
# ["(0) Mammal", 1], | |
# ["(0) Mammal | (0) Dog", 3], | |
# ["(0) Mammal | (0) Dog | (0) Dobey", 6], | |
# ["(0) Mammal | (0) Dog | (1) Beagle", 5], | |
# ["(0) Mammal | (1) Cow", 4], | |
# ["(0) Mammal | (2) Cat", 2] | |
# ] | |
def test_hash | |
{ | |
OpenStruct.new(id: 1, title: "Mammal", pos_level: 0) => { | |
OpenStruct.new(id: 3, title: "Dog", pos_level: 0) => { | |
OpenStruct.new(id: 6, title: "Dobey", pos_level: 0) => {}, | |
OpenStruct.new(id: 5, title: "Beagle", pos_level: 1) => {} | |
}, | |
OpenStruct.new(id: 4, title: "Cow", pos_level: 1) => {}, | |
OpenStruct.new(id: 2, title: "Cat", pos_level: 2) => {} | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment