Class: Sol::IfNode
- Inherits:
-
Struct
- Object
- Struct
- Sol::IfNode
- Defined in:
- lib/sol/nodes.rb,
lib/sol/interpreter.rb
Overview
“if” control structure. Look at this node if you want to implement other control structures like while, for, loop, etc.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#condition ⇒ Object
Returns the value of attribute condition.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
77 78 79 |
# File 'lib/sol/nodes.rb', line 77 def body @body end |
#condition ⇒ Object
Returns the value of attribute condition
77 78 79 |
# File 'lib/sol/nodes.rb', line 77 def condition @condition end |
Instance Method Details
#eval(context) ⇒ Object
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/sol/interpreter.rb', line 174 def eval(context) # We turn the condition node innto a Ruby value to use Ruby's "if" control structure if condition.eval(context).ruby_value body.eval(context) end end |