Class: IfNode

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

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



46
47
48
# File 'lib/turmali/nodes.rb', line 46

def body
  @body
end

#conditionObject

Returns the value of attribute condition

Returns:

  • (Object)

    the current value of condition



46
47
48
# File 'lib/turmali/nodes.rb', line 46

def condition
  @condition
end

Instance Method Details

#eval(context) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/turmali/interpreter.rb', line 119

def eval(context)
  if condition.eval(context).ruby_value
    body.eval(context)
  else 
    Constants["nil"]
  end
end