Class: Rambling::Trie::Nodes::Compressed
- Defined in:
- lib/rambling/trie/nodes/compressed.rb
Overview
A representation of a node in an compressed trie data structure. :reek:RepeatedConditional { max_ifs: 4 }
Constant Summary
Constants included from Enumerable
Instance Attribute Summary
Attributes inherited from Node
#children_tree, #letter, #parent
Instance Method Summary collapse
-
#add(_) ⇒ void
Always raises InvalidOperation when trying to add a word to the current compressed trie node.
-
#compressed? ⇒ Boolean
Always return ‘true` for a compressed node.
-
#initialize(letter = nil, parent = nil, children_tree = {}) ⇒ Compressed
constructor
Creates a new compressed node.
Methods inherited from Node
#[], #[]=, #children, #delete, #first_child, #key?, #match_prefix, #partial_word?, #root?, #scan, #terminal!, #terminal?, #word?
Methods included from Inspectable
Methods included from Stringifyable
Methods included from Comparable
Methods included from Enumerable
Methods included from Compressible
Constructor Details
#initialize(letter = nil, parent = nil, children_tree = {}) ⇒ Compressed
Creates a new compressed node.
13 14 15 16 17 18 |
# File 'lib/rambling/trie/nodes/compressed.rb', line 13 def initialize letter = nil, parent = nil, children_tree = {} super # Ensure all children have the current compressed node as the parent children_tree.each_value { |child| child.parent = self } end |
Instance Method Details
#add(_) ⇒ void
This method returns an undefined value.
Always raises InvalidOperation when trying to add a word to the current compressed trie node
25 26 27 |
# File 'lib/rambling/trie/nodes/compressed.rb', line 25 def add _ raise Rambling::Trie::InvalidOperation, 'Cannot add word to compressed trie' end |
#compressed? ⇒ Boolean
Always return ‘true` for a compressed node.
31 32 33 |
# File 'lib/rambling/trie/nodes/compressed.rb', line 31 def compressed? true end |