Class: Rley::SPPF::CompositeNode

Inherits:
SPPFNode
  • Object
show all
Defined in:
lib/rley/sppf/composite_node.rb

Overview

Abstract class. The generalization for nodes that have children node(s).

Direct Known Subclasses

AlternativeNode, NonTerminalNode

Instance Attribute Summary collapse

Attributes inherited from SPPFNode

#range

Instance Method Summary collapse

Methods inherited from SPPFNode

#origin

Constructor Details

#initialize(aRange) ⇒ CompositeNode

Returns a new instance of CompositeNode.



11
12
13
14
# File 'lib/rley/sppf/composite_node.rb', line 11

def initialize(aRange)
  super(aRange)
  @subnodes = []
end

Instance Attribute Details

#subnodesObject (readonly)

Array of sub-nodes.



9
10
11
# File 'lib/rley/sppf/composite_node.rb', line 9

def subnodes
  @subnodes
end

Instance Method Details

#add_subnode(aSubnode) ⇒ Object



16
17
18
# File 'lib/rley/sppf/composite_node.rb', line 16

def add_subnode(aSubnode)
  subnodes.unshift(aSubnode)
end

#keyObject



20
21
22
# File 'lib/rley/sppf/composite_node.rb', line 20

def key()
  @key ||= to_string(0)
end