Class: Squeel::Nodes::Unary

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

Overview

A node that contains a single expression.

Direct Known Subclasses

Grouping, Not

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PredicateOperators

#&, #[email protected], #|

Methods inherited from Node

#each, #grep

Constructor Details

#initialize(expr) ⇒ Unary

Create a new Unary node.

Parameters:

  • expr

    The expression to contain inside the node.


13
14
15
# File 'lib/squeel/nodes/unary.rb', line 13

def initialize(expr)
  @expr = expr
end

Instance Attribute Details

#exprObject (readonly)

Returns The expression contained in the node

Returns:

  • The expression contained in the node


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

def expr
  @expr
end

Instance Method Details

#eql?(other) ⇒ Boolean

Object comparison

Returns:

  • (Boolean)

22
23
24
25
# File 'lib/squeel/nodes/unary.rb', line 22

def eql?(other)
  self.class.eql?(other.class) &&
  self.expr.eql?(other.expr)
end

#hashObject


17
18
19
# File 'lib/squeel/nodes/unary.rb', line 17

def hash
  @expr.hash
end