Class: Rambling::Trie::Nodes::Compressed

Inherits:
Node
  • Object
show all
Defined in:
lib/rambling/trie/nodes/compressed.rb

Overview

A representation of a node in an compressed trie data structure.

Instance Attribute Summary

Attributes inherited from Node

#children_tree, #letter, #parent

Instance Method Summary collapse

Methods inherited from Node

#[], #[]=, #children, #delete, #first_child, #initialize, #key?, #match_prefix, #partial_word?, #root?, #scan, #terminal!, #terminal?, #word?

Methods included from Inspectable

#inspect

Methods included from Stringifyable

#as_word, #to_s

Methods included from Comparable

#==

Methods included from Enumerable

#each

Methods included from Compressible

#compressible?

Constructor Details

This class inherits a constructor from Rambling::Trie::Nodes::Node

Instance Method Details

#add(_) ⇒ nil

Always raises InvalidOperation when trying to add a word to the current compressed trie node

Parameters:

  • _ (String)

    the word to add to the trie.

Returns:

  • (nil)

    this never returns as it always raises an exception.

Raises:



13
14
15
16
# File 'lib/rambling/trie/nodes/compressed.rb', line 13

def add _
  raise Rambling::Trie::InvalidOperation,
    'Cannot add word to compressed trie'
end

#compressed?Boolean

Always return ‘true` for a compressed node.

Returns:

  • (Boolean)

    always ‘true` for a compressed node.



20
21
22
# File 'lib/rambling/trie/nodes/compressed.rb', line 20

def compressed?
  true
end