Class: JMESPath::Nodes::Comparator Private

Inherits:
Node
  • Object
show all
Defined in:
lib/jmespath/nodes/comparator.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

COMPARABLE_TYPES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[Numeric, String].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#chains_with?

Constructor Details

#initialize(left, right) ⇒ Comparator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Comparator.



10
11
12
13
# File 'lib/jmespath/nodes/comparator.rb', line 10

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

Instance Attribute Details

#leftObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/jmespath/nodes/comparator.rb', line 8

def left
  @left
end

#rightObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/jmespath/nodes/comparator.rb', line 8

def right
  @right
end

Class Method Details

.create(relation, left, right) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jmespath/nodes/comparator.rb', line 15

def self.create(relation, left, right)
  type = begin
    case relation
    when '==' then Comparators::Eq
    when '!=' then Comparators::Neq
    when '>' then Comparators::Gt
    when '>=' then Comparators::Gte
    when '<' then Comparators::Lt
    when '<=' then Comparators::Lte
    end
  end
  type.new(left, right)
end

Instance Method Details

#optimizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
# File 'lib/jmespath/nodes/comparator.rb', line 33

def optimize
  self.class.new(@left.optimize, @right.optimize)
end

#visit(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/jmespath/nodes/comparator.rb', line 29

def visit(value)
  check(@left.visit(value), @right.visit(value))
end