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

Constructor

Parameters:



13
14
15
16
# File 'lib/rley/sppf/composite_node.rb', line 13

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

Instance Attribute Details

#subnodesArray<SPFFNode> (readonly)

Returns Sub-nodes (children).

Returns:

  • (Array<SPFFNode>)

    Sub-nodes (children).



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

def subnodes
  @subnodes
end

Instance Method Details

#add_subnode(aSubnode) ⇒ Object

Add a sub-node (child) to this one.

Parameters:



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

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

#inspectString

Returns a text representation of the node.

Returns:

  • (String)

    a text representation of the node.



25
26
27
# File 'lib/rley/sppf/composite_node.rb', line 25

def inspect()
  key
end

#keyString

Returns:

  • (String)


30
31
32
# File 'lib/rley/sppf/composite_node.rb', line 30

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