Class: JMESPath::Nodes::Comparator Private

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

Overview

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.

API:

  • private

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#chains_with?, #hash_like?

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.

API:

  • private



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

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.

API:

  • private



5
6
7
# File 'lib/jmespath/nodes/comparator.rb', line 5

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.

API:

  • private



5
6
7
# File 'lib/jmespath/nodes/comparator.rb', line 5

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.

API:

  • private



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jmespath/nodes/comparator.rb', line 12

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.

API:

  • private



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

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.

API:

  • private



26
27
28
# File 'lib/jmespath/nodes/comparator.rb', line 26

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