Class: Dentaku::AST::If
- Defined in:
- lib/dentaku/ast/functions/if.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #dependencies(context = {}) ⇒ Object
-
#initialize(predicate, left, right) ⇒ If
constructor
A new instance of If.
- #type ⇒ Object
- #value(context = {}) ⇒ Object
Methods inherited from Function
Methods inherited from Node
Constructor Details
#initialize(predicate, left, right) ⇒ If
Returns a new instance of If.
8 9 10 11 12 |
# File 'lib/dentaku/ast/functions/if.rb', line 8 def initialize(predicate, left, right) @predicate = predicate @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
6 7 8 |
# File 'lib/dentaku/ast/functions/if.rb', line 6 def left @left end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
6 7 8 |
# File 'lib/dentaku/ast/functions/if.rb', line 6 def predicate @predicate end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
6 7 8 |
# File 'lib/dentaku/ast/functions/if.rb', line 6 def right @right end |
Instance Method Details
#dependencies(context = {}) ⇒ Object
22 23 24 25 |
# File 'lib/dentaku/ast/functions/if.rb', line 22 def dependencies(context={}) # TODO : short-circuit? (predicate.dependencies(context) + left.dependencies(context) + right.dependencies(context)).uniq end |
#type ⇒ Object
18 19 20 |
# File 'lib/dentaku/ast/functions/if.rb', line 18 def type left.type end |
#value(context = {}) ⇒ Object
14 15 16 |
# File 'lib/dentaku/ast/functions/if.rb', line 14 def value(context={}) predicate.value(context) ? left.value(context) : right.value(context) end |