Class: EXEL::ASTNode

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

Direct Known Subclasses

InstructionNode, SequenceNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instruction, children = []) ⇒ ASTNode

Returns a new instance of ASTNode.



5
6
7
8
# File 'lib/exel/ast_node.rb', line 5

def initialize(instruction, children = [])
  @instruction = instruction
  @children = children
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



3
4
5
# File 'lib/exel/ast_node.rb', line 3

def children
  @children
end

#instructionObject (readonly)

Returns the value of attribute instruction.



3
4
5
# File 'lib/exel/ast_node.rb', line 3

def instruction
  @instruction
end

Instance Method Details

#add_child(node) ⇒ Object



18
19
20
# File 'lib/exel/ast_node.rb', line 18

def add_child(node)
  @children << node
end

#run(_context) ⇒ Object



14
15
16
# File 'lib/exel/ast_node.rb', line 14

def run(_context)
  fail "#{self.class} does not implement #process"
end

#start(context) ⇒ Object



10
11
12
# File 'lib/exel/ast_node.rb', line 10

def start(context)
  fail_silently { run(context) }
end