Class: Dawg::MemoryNode
- Inherits:
-
Object
- Object
- Dawg::MemoryNode
- Defined in:
- lib/dawg/node/memory_node.rb
Instance Attribute Summary collapse
-
#edge_count ⇒ Object
Returns the value of attribute edge_count.
-
#edges_pos ⇒ Object
Returns the value of attribute edges_pos.
-
#final ⇒ Object
Returns the value of attribute final.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#index ⇒ Object
Returns the value of attribute index.
-
#io ⇒ Object
Returns the value of attribute io.
Instance Method Summary collapse
- #[](letter) ⇒ Object
- #each_edge(&block) ⇒ Object
-
#initialize(io, index, edge_count, final, hash, edges_pos) ⇒ MemoryNode
constructor
A new instance of MemoryNode.
Constructor Details
#initialize(io, index, edge_count, final, hash, edges_pos) ⇒ MemoryNode
Returns a new instance of MemoryNode.
4 5 6 7 8 9 10 11 |
# File 'lib/dawg/node/memory_node.rb', line 4 def initialize(io, index , edge_count , final, hash, edges_pos ) @io = io @index = index @edge_count = edge_count @final = final @hash = hash @edges_pos = edges_pos end |
Instance Attribute Details
#edge_count ⇒ Object
Returns the value of attribute edge_count.
3 4 5 |
# File 'lib/dawg/node/memory_node.rb', line 3 def edge_count @edge_count end |
#edges_pos ⇒ Object
Returns the value of attribute edges_pos.
3 4 5 |
# File 'lib/dawg/node/memory_node.rb', line 3 def edges_pos @edges_pos end |
#final ⇒ Object
Returns the value of attribute final.
3 4 5 |
# File 'lib/dawg/node/memory_node.rb', line 3 def final @final end |
#hash ⇒ Object
Returns the value of attribute hash.
3 4 5 |
# File 'lib/dawg/node/memory_node.rb', line 3 def hash @hash end |
#index ⇒ Object
Returns the value of attribute index.
3 4 5 |
# File 'lib/dawg/node/memory_node.rb', line 3 def index @index end |
#io ⇒ Object
Returns the value of attribute io.
3 4 5 |
# File 'lib/dawg/node/memory_node.rb', line 3 def io @io end |
Instance Method Details
#[](letter) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/dawg/node/memory_node.rb', line 13 def [](letter) @io.each_edge @index do |char, node_index| if letter == char return @io.get_node_by_index(node_index) end end nil end |
#each_edge(&block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/dawg/node/memory_node.rb', line 23 def each_edge(&block) @io.each_edge @index do |char, node_index| yield char end end |