class Node
Constants
- CURRENT_ENDING_OFFSET
Leaf nodes use this due to Rule 1: once a leaf, always a leaf
- LEAF_DEPTH
Leaf nodes get special depth, since they vary as characters get added
- UNSPECIFIED_OFFSET
Root uses this, it has no incoming edge, yet as a
Node
has incoming edge offset properties
Attributes
children[RW]
incomingEdgeEndOffset[RW]
incomingEdgeStartOffset[RW]
nodeId[R]
parent[RW]
suffixLink[RW]
suffixOffset[RW]
Public Class Methods
new(nodeId, suffixOffset = UNSPECIFIED_OFFSET)
click to toggle source
# File lib/support/node.rb, line 15 def initialize(nodeId, suffixOffset = UNSPECIFIED_OFFSET) @nodeId = nodeId @incomingEdgeStartOffset = UNSPECIFIED_OFFSET @incomingEdgeEndOffset = UNSPECIFIED_OFFSET @suffixOffset = suffixOffset @parent = nil @suffixLink = nil @children = nil end
Public Instance Methods
createAccessor(name)
click to toggle source
some algorithms require additional accessors, allow these to be created dynamically
# File lib/support/node.rb, line 45 def createAccessor(name) self.class.send(:attr_accessor, name) end
each_suffix() { |suffixOffset| ... }
click to toggle source
suffix offset enumerator (not sure this belongs here)
# File lib/support/node.rb, line 52 def each_suffix if (self.isLeaf) then yield suffixOffset else children.keys.sort.each do |key| children[key].each_suffix do |suffixOffset| yield suffixOffset end end end end
incomingEdgeLength()
click to toggle source
# File lib/support/node.rb, line 38 def incomingEdgeLength return @incomingEdgeEndOffset - @incomingEdgeStartOffset + 1 end
isInternal()
click to toggle source
# File lib/support/node.rb, line 34 def isInternal return !isLeaf && !isRoot end
isLeaf()
click to toggle source
# File lib/support/node.rb, line 30 def isLeaf return @incomingEdgeEndOffset == CURRENT_ENDING_OFFSET end
isRoot()
click to toggle source
# File lib/support/node.rb, line 26 def isRoot return @parent == nil end