Module: Rambling::Trie::Enumerable
Overview
Provides enumerable behavior to the trie data structure.
Instance Method Summary collapse
-
#each {|String| ... } ⇒ Object
Iterates over the words contained in the trie.
Instance Method Details
#each {|String| ... } ⇒ Object
Iterates over the words contained in the trie.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rambling/trie/enumerable.rb', line 16 def each return enum_for :each unless block_given? yield as_word if terminal? children_tree.each_value do |child| child.each do |word| yield word end end end |