module Rambling::Trie::Stringifyable
Provides the String
representation behavior for the trie data structure.
Public Instance Methods
as_word()
click to toggle source
String representation of the current node, if it is a terminal node. @return [String] the string representation of the current node. @raise [InvalidOperation] if node is not terminal or is root.
# 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()
click to toggle source
String representation of the current node. @return [String] the string representation of the current node.
# File lib/rambling/trie/stringifyable.rb, line 21 def to_s parent.to_s + letter.to_s end