Class: CriteriaOperator::UnaryOperator

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

Overview

Operator representing an unary operation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseOperator

deserialize, serialize, #serialize

Constructor Details

#initialize(operand = nil, unary_operator_type = UnaryOperatorType::NOT) ⇒ Void

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

Parameters:

  • operand (BaseOperator) (defaults to: nil)

    the operand

  • unary_operator_type (UnaryOperatorType) (defaults to: UnaryOperatorType::NOT)

    the type of this operator



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

def initialize(operand = nil, unary_operator_type = UnaryOperatorType::NOT)
  self.operand = operand
  self.operator_type = unary_operator_type
end

Instance Attribute Details

#operandBaseOperator

Returns the operand.

Returns:



24
25
26
# File 'lib/criteria_operator/unary_operator.rb', line 24

def operand
  @operand
end

#operator_typeUnaryOperatorType

Returns the type of this operator.

Returns:



21
22
23
# File 'lib/criteria_operator/unary_operator.rb', line 21

def operator_type
  @operator_type
end

Instance Method Details

#cloneUnaryOperator

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

Returns:



38
39
40
# File 'lib/criteria_operator/unary_operator.rb', line 38

def clone
  UnaryOperator.new clone_or_nil(self.operand), self.operator_type
end