Class: Confuscript::Nodes::ProgramNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/confuscript/nodes/program_node.rb

Instance Method Summary collapse

Methods inherited from BaseNode

#find_node

Instance Method Details

#childrenObject



11
12
13
# File 'lib/confuscript/nodes/program_node.rb', line 11

def children
  elements[1]&.elements || []
end

#evaluate(context) ⇒ Object



4
5
6
7
8
9
# File 'lib/confuscript/nodes/program_node.rb', line 4

def evaluate(context)
  # Not the best way to evaluate
  # TODO:- Revisit this
  # Evaluate all children and return the result of the last one
  children.map { |child| child.elements[0].evaluate(context) }.last
end

#first_childObject



15
16
17
# File 'lib/confuscript/nodes/program_node.rb', line 15

def first_child
  children.first&.elements&.first
end