Module: Rambling::Trie::Stringifyable
- Included in:
- Nodes::Node
- Defined in:
- lib/rambling/trie/stringifyable.rb
Overview
Provides the String representation behavior for the trie data structure.
Instance Method Summary collapse
-
#as_word ⇒ String
String representation of the current node, if it is a terminal node.
-
#to_s ⇒ String
String representation of the current node.
Instance Method Details
#as_word ⇒ String
String representation of the current node, if it is a terminal node.
10 11 12 13 14 15 16 17 |
# File 'lib/rambling/trie/stringifyable.rb', line 10 def as_word if letter && !terminal? raise Rambling::Trie::InvalidOperation, 'Cannot represent branch as a word' end to_s end |
#to_s ⇒ String
String representation of the current node.
21 22 23 |
# File 'lib/rambling/trie/stringifyable.rb', line 21 def to_s parent.to_s + letter.to_s end |