Module: BinaryOperator
- Included in:
- EqualsOperator, GreaterThanOperator, GreaterThanOrEqualOperator, InOperator, LessThanOperator, LessThanOrEqualOperator, MatchOperator, ValueOperator, VarOperator
- Defined in:
- lib/json_expr/operators/binary_operator.rb
Instance Method Summary collapse
Instance Method Details
#binary(evaluator, lhs, rhs) ⇒ Object
This method is abstract.
method
19 20 21 |
# File 'lib/json_expr/operators/binary_operator.rb', line 19 def binary(evaluator, lhs, rhs) raise NotImplementedError.new("You must implement binary method.") end |
#evaluate(evaluator, args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/json_expr/operators/binary_operator.rb', line 4 def evaluate(evaluator, args) if args.is_a? Array args_list = args lhs = args_list.size > 0 ? evaluator.evaluate(args_list[0]) : nil unless lhs.nil? rhs = args_list.size > 1 ? evaluator.evaluate(args_list[1]) : nil unless rhs.nil? return binary(evaluator, lhs, rhs) end end end nil end |