Class: RubyTrie::TrieContent

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_trie.rb

Overview

the content of a TrieNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, value = nil) ⇒ TrieContent

Initialize with the full string (not just the symbol) and an optional value You should not need to use this class unless you start walking the Trie



28
29
30
31
32
# File 'lib/ruby_trie.rb', line 28

def initialize(str, value=nil)
   @string = str
   @symbol = str[-1]
   @value = value
end

Instance Attribute Details

#stringObject (readonly)

symbol at the node, and the entire string to this node are held



19
20
21
# File 'lib/ruby_trie.rb', line 19

def string
  @string
end

#symbolObject (readonly)

symbol at the node, and the entire string to this node are held



19
20
21
# File 'lib/ruby_trie.rb', line 19

def symbol
  @symbol
end

#valueObject

value can be overwritten



22
23
24
# File 'lib/ruby_trie.rb', line 22

def value
  @value
end

Instance Method Details

#to_aObject

turn the content into a [symbol, string, value] array



35
36
37
# File 'lib/ruby_trie.rb', line 35

def to_a
   [@symbol, @string, @value]
end