Class: WhileNode

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



48
49
50
# File 'lib/turmali/nodes.rb', line 48

def body
  @body
end

#conditionObject

Returns the value of attribute condition

Returns:

  • (Object)

    the current value of condition



48
49
50
# File 'lib/turmali/nodes.rb', line 48

def condition
  @condition
end

Instance Method Details

#eval(context) ⇒ Object



129
130
131
132
133
134
# File 'lib/turmali/interpreter.rb', line 129

def eval(context)
  while @condition.eval(context).ruby_value
    @body.eval(context)
  end
  Constants["nil"]
end