Class: Rjq::AST::BinaryOp
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Node
Instance Method Summary collapse
- #eval(input, context) ⇒ Object
-
#initialize(left, op, right) ⇒ BinaryOp
constructor
A new instance of BinaryOp.
Methods inherited from Node
#assign_value, #invalid_path_message, #paths, #take, #with_source_span
Constructor Details
#initialize(left, op, right) ⇒ BinaryOp
Returns a new instance of BinaryOp.
816 817 818 819 820 |
# File 'lib/rjq/ast.rb', line 816 def initialize(left, op, right) @left = left @op = op @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
814 815 816 |
# File 'lib/rjq/ast.rb', line 814 def left @left end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
814 815 816 |
# File 'lib/rjq/ast.rb', line 814 def op @op end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
814 815 816 |
# File 'lib/rjq/ast.rb', line 814 def right @right end |
Instance Method Details
#eval(input, context) ⇒ Object
822 823 824 825 826 827 828 829 830 831 |
# File 'lib/rjq/ast.rb', line 822 def eval(input, context) return eval_alternative(input, context) if @op == '//' return eval_boolean(input, context) if @op == 'and' || @op == 'or' left_values = @left.eval(input, context) right_values = @right.eval(input, context) left_values.flat_map do |left| right_values.map { |right| apply(left, right) } end end |