Class: CriteriaOperator::BinaryOperator

Inherits:
BaseOperator show all
Defined in:
lib/criteria_operator/binary_operator.rb

Overview

Operator representing any of the binary conditionals defined in BinaryOperatorType.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseOperator

deserialize, serialize, #serialize

Constructor Details

#initialize(left_operand = nil, right_operand = nil, binary_operator_type = BinaryOperatorType::EQUAL) ⇒ Void

The constructor for this operator. Expects the operands and the operator type as parameters.

Parameters:

  • left_operand (BaseOperator) (defaults to: nil)

    the left hand side operand

  • right_operand (BaseOperator) (defaults to: nil)

    the right hand side operand

  • binary_operator_type (BinaryOperatorType) (defaults to: BinaryOperatorType::EQUAL)

    the type of this operator



38
39
40
41
42
# File 'lib/criteria_operator/binary_operator.rb', line 38

def initialize(left_operand = nil, right_operand = nil, binary_operator_type = BinaryOperatorType::EQUAL)
  self.left_operand = left_operand
  self.right_operand = right_operand
  self.operator_type = binary_operator_type
end

Instance Attribute Details

#left_operandBaseOperator

Returns the left hand side operand.

Returns:



28
29
30
# File 'lib/criteria_operator/binary_operator.rb', line 28

def left_operand
  @left_operand
end

#operator_typeBinaryOperatorType

Returns the type of this operator.

Returns:



25
26
27
# File 'lib/criteria_operator/binary_operator.rb', line 25

def operator_type
  @operator_type
end

#right_operandBaseOperator

Returns the right hand side operand.

Returns:



31
32
33
# File 'lib/criteria_operator/binary_operator.rb', line 31

def right_operand
  @right_operand
end

Instance Method Details

#cloneBinaryOperator

Clones an operator with all sub-operators, creating a deep copy. Implementation of the abstract CriteriaOperator::BaseOperator#clone.

Returns:



47
48
49
# File 'lib/criteria_operator/binary_operator.rb', line 47

def clone
  BinaryOperator.new clone_or_nil(self.left_operand), clone_or_nil(self.right_operand), self.operator_type
end