-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Node
an Enumerable
#24
Conversation
The use case I was working with was iterating through a node's direct children without descending into the tree. So renaming Another possibility is to return an items = parent.each_child.select { |child| child.type == :list_item } |
Cool, I got you. I renamed |
each do |child| | ||
child.walk(&block) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to return an Enumerator
from walk
, if no block is given, to match the behavior of each
.
Closes #23.
@dgraham, how's this work for you?
walk
has been renamedeach
so that all theEnumerable
methods can function. I only added a test forselect
but can add more if you think there's something to explicitly test.