Module: Rambling::Trie::Stringifyable
- Included in:
- Nodes::Node
- Defined in:
- lib/rambling/trie/stringifyable.rb,
sig/lib/rambling/trie/stringifyable.rbs
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.
- #children_tree ⇒ Hash[Symbol, Nodes::Node[TValue]]
- #letter ⇒ Symbol?
- #parent ⇒ Nodes::Node[TValue]?
- #terminal? ⇒ Boolean
-
#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 |
# File 'lib/rambling/trie/stringifyable.rb', line 10 def as_word raise Rambling::Trie::InvalidOperation, 'Cannot represent branch as a word' if letter && !terminal? to_s end |
#children_tree ⇒ Hash[Symbol, Nodes::Node[TValue]]
18 |
# File 'sig/lib/rambling/trie/stringifyable.rbs', line 18 def children_tree: -> Hash[Symbol, Nodes::Node[TValue]] |
#letter ⇒ Symbol?
12 |
# File 'sig/lib/rambling/trie/stringifyable.rbs', line 12 def letter: -> Symbol? |
#parent ⇒ Nodes::Node[TValue]?
16 |
# File 'sig/lib/rambling/trie/stringifyable.rbs', line 16 def parent: -> Nodes::Node[TValue]? |
#terminal? ⇒ Boolean
14 |
# File 'sig/lib/rambling/trie/stringifyable.rbs', line 14 def terminal?: -> bool |
#to_s ⇒ String
String representation of the current node.
18 19 20 |
# File 'lib/rambling/trie/stringifyable.rb', line 18 def to_s parent.to_s + letter.to_s end |