Class: Nodes

Inherits:
Struct
  • Object
show all
Defined in:
lib/turmali/nodes.rb,
lib/turmali/interpreter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes

Returns:

  • (Object)

    the current value of nodes



1
2
3
# File 'lib/turmali/nodes.rb', line 1

def nodes
  @nodes
end

Instance Method Details

#<<(node) ⇒ Object

Useful method for adding a node on the fly.



2
3
4
5
# File 'lib/turmali/nodes.rb', line 2

def <<(node) # Useful method for adding a node on the fly.
  nodes << node
  self
end

#eval(context) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/turmali/interpreter.rb', line 19

def eval(context)
  return_value = nil
  nodes.each do |node|
    return_value = node.eval(context)
  end
  return_value || Constants["nil"] 
end