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.


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


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

def left_operand
  @left_operand
end

#operator_typeBinaryOperatorType


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

def operator_type
  @operator_type
end

#right_operandBaseOperator


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.


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