Class: Gobstones::Lang::Commands::IfThenElse
- Inherits:
-
If
- Object
- Conditional
- If
- Gobstones::Lang::Commands::IfThenElse
- Defined in:
- lib/gobstones/lang/commands/if_then_else.rb
Instance Attribute Summary collapse
-
#else_block ⇒ Object
readonly
Returns the value of attribute else_block.
Attributes inherited from Conditional
Instance Method Summary collapse
- #equality_attributes ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(condition, then_block, else_block) ⇒ IfThenElse
constructor
A new instance of IfThenElse.
Methods inherited from Conditional
Methods included from EqualityDefinition
Constructor Details
#initialize(condition, then_block, else_block) ⇒ IfThenElse
Returns a new instance of IfThenElse.
9 10 11 12 |
# File 'lib/gobstones/lang/commands/if_then_else.rb', line 9 def initialize(condition, then_block, else_block) super(condition, then_block) @else_block = else_block end |
Instance Attribute Details
#else_block ⇒ Object (readonly)
Returns the value of attribute else_block.
7 8 9 |
# File 'lib/gobstones/lang/commands/if_then_else.rb', line 7 def else_block @else_block end |
Instance Method Details
#equality_attributes ⇒ Object
14 15 16 |
# File 'lib/gobstones/lang/commands/if_then_else.rb', line 14 def equality_attributes super + [:else_block] end |
#evaluate(context) ⇒ Object
18 19 20 21 22 |
# File 'lib/gobstones/lang/commands/if_then_else.rb', line 18 def evaluate(context) evaluate_condition(context). if_true(then_block, context). if_false(else_block, context) end |