Class: Squeel::Nodes::Binary

Inherits:
Node
  • Object
show all
Includes:
PredicateOperators
Defined in:
lib/squeel/nodes/binary.rb

Overview

A node that represents an operation with two operands.

Direct Known Subclasses

As, Or

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PredicateOperators

#&, #-@, #|

Methods inherited from Node

#each, #grep

Constructor Details

#initialize(left, right) ⇒ Binary

Returns a new instance of Binary

Parameters:

  • left

    The left operand

  • right

    The right operand



16
17
18
# File 'lib/squeel/nodes/binary.rb', line 16

def initialize(left, right)
  @left, @right = left, right
end

Instance Attribute Details

#leftObject (readonly)

The left operand



9
10
11
# File 'lib/squeel/nodes/binary.rb', line 9

def left
  @left
end

#rightObject (readonly)

The right operand



12
13
14
# File 'lib/squeel/nodes/binary.rb', line 12

def right
  @right
end

Instance Method Details

#eql?(other) ⇒ Boolean

Comparison with other nodes

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/squeel/nodes/binary.rb', line 25

def eql?(other)
  self.class.eql?(other.class) &&
  self.left.eql?(other.left) &&
  self.right.eql?(other.right)
end

#hashObject



20
21
22
# File 'lib/squeel/nodes/binary.rb', line 20

def hash
  [@left, @right].hash
end