Class: Kalc::Ast::Conditional
- Inherits:
-
Object
- Object
- Kalc::Ast::Conditional
- Defined in:
- lib/kalc/ast.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#false_cond ⇒ Object
readonly
Returns the value of attribute false_cond.
-
#true_cond ⇒ Object
readonly
Returns the value of attribute true_cond.
Instance Method Summary collapse
- #eval(context) ⇒ Object
-
#initialize(condition, true_cond, false_cond) ⇒ Conditional
constructor
A new instance of Conditional.
Constructor Details
#initialize(condition, true_cond, false_cond) ⇒ Conditional
Returns a new instance of Conditional.
187 188 189 190 191 |
# File 'lib/kalc/ast.rb', line 187 def initialize(condition, true_cond, false_cond) @condition = condition @true_cond = true_cond @false_cond = false_cond end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
185 186 187 |
# File 'lib/kalc/ast.rb', line 185 def condition @condition end |
#false_cond ⇒ Object (readonly)
Returns the value of attribute false_cond.
185 186 187 |
# File 'lib/kalc/ast.rb', line 185 def false_cond @false_cond end |
#true_cond ⇒ Object (readonly)
Returns the value of attribute true_cond.
185 186 187 |
# File 'lib/kalc/ast.rb', line 185 def true_cond @true_cond end |
Instance Method Details
#eval(context) ⇒ Object
193 194 195 |
# File 'lib/kalc/ast.rb', line 193 def eval(context) @condition.eval(context) ? @true_cond.eval(context) : @false_cond.eval(context) end |