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.


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

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

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children


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

def children
  @children
end

#instructionObject (readonly)

Returns the value of attribute instruction


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

def instruction
  @instruction
end

Instance Method Details

#add_child(node) ⇒ Object


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

def add_child(node)
  @children << node
end

#run(_context) ⇒ Object


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

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

#start(context) ⇒ Object


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

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