Class: EXEL::ASTNode

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

Overview

An abstract class that serves as the parent class of nodes in the AST

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.



7
8
9
10
# File 'lib/exel/ast_node.rb', line 7

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

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



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

def children
  @children
end

#instructionObject (readonly)

Returns the value of attribute instruction.



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

def instruction
  @instruction
end

Instance Method Details

#add_child(node) ⇒ Object



22
23
24
# File 'lib/exel/ast_node.rb', line 22

def add_child(node)
  @children << node
end

#run(_context) ⇒ Object



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

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

#start(context) ⇒ Object



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

def start(context)
  run(context)
rescue EXEL::Error::JobTermination => e
  EXEL.logger.send(e.cmd, "JobTerminationError: #{e.message.chomp}")
end