Sha256: 279ad617e7aa2b38d6e0692c1e7a522967fef16c35fcdb30670fe2fafe8f2ca1

Contents?: true

Size: 550 Bytes

Versions: 8

Compression:

Stored size: 550 Bytes

Contents

# frozen_string_literal: true

module BinaryOperator
  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

  # @abstract method
  def binary(evaluator, lhs, rhs)
    raise NotImplementedError.new("You must implement binary method.")
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
absmartly-sdk-1.1.2 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-1.1.1 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-1.1.0 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-1.0.8 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-1.0.7 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-1.0.6 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-1.0.5 lib/json_expr/operators/binary_operator.rb
absmartly-sdk-0.1.2 lib/json_expr/operators/binary_operator.rb