Module: Rambling::Trie::Enumerable
Overview
Provides enumerable behavior to the trie data structure.
Constant Summary collapse
- EMPTY_ENUMERATOR =
Empty enumerator constant for early each exits.
[].to_enum :each
Instance Method Summary collapse
-
#each {|String| ... } ⇒ self
Iterates over the words contained in the trie.
Instance Method Details
#each {|String| ... } ⇒ self
Iterates over the words contained in the trie.
19 20 21 22 23 24 25 26 27 |
# File 'lib/rambling/trie/enumerable.rb', line 19 def each return enum_for :each unless block_given? yield as_word if terminal? children_tree.each_value { |child| child.each { |word| yield word } } self end |