Class: Dentaku::AST::If
- Defined in:
- lib/dentaku/ast/functions/if.rb
Constant Summary
Constants inherited from Function
Constants inherited from Node
Node::STATIC_CONTEXT, Node::STATIC_MODE_KEY
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.
Class Method Summary collapse
Instance Method Summary collapse
- #args ⇒ Object
- #dependencies(context = {}) ⇒ Object
-
#initialize(predicate, left, right) ⇒ If
constructor
A new instance of If.
- #node_type ⇒ Object
- #type ⇒ Object
- #value(context = {}) ⇒ Object
Methods inherited from Function
#accept, get, register, register_class, registry, volatile?
Methods inherited from Node
arity, #name, precedence, #pure?, resolve_class
Constructor Details
#initialize(predicate, left, right) ⇒ If
Returns a new instance of If.
16 17 18 19 20 |
# File 'lib/dentaku/ast/functions/if.rb', line 16 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 |
Class Method Details
.max_param_count ⇒ Object
12 13 14 |
# File 'lib/dentaku/ast/functions/if.rb', line 12 def self.max_param_count 3 end |
.min_param_count ⇒ Object
8 9 10 |
# File 'lib/dentaku/ast/functions/if.rb', line 8 def self.min_param_count 3 end |
Instance Method Details
#args ⇒ Object
22 23 24 |
# File 'lib/dentaku/ast/functions/if.rb', line 22 def args [predicate, left, right] end |
#dependencies(context = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dentaku/ast/functions/if.rb', line 38 def dependencies(context = {}) return all_arg_dependencies(context) if static_mode?(context) || !predicate.pure? predicate.value(context) ? left.dependencies(context) : right.dependencies(context) rescue Dentaku::Error all_arg_dependencies(context) end |
#node_type ⇒ Object
30 31 32 |
# File 'lib/dentaku/ast/functions/if.rb', line 30 def node_type :condition end |
#type ⇒ Object
34 35 36 |
# File 'lib/dentaku/ast/functions/if.rb', line 34 def type left.type end |
#value(context = {}) ⇒ Object
26 27 28 |
# File 'lib/dentaku/ast/functions/if.rb', line 26 def value(context = {}) predicate.value(context) ? left.value(context) : right.value(context) end |