class JMESPath::Nodes::Comparator
Constants
- COMPARABLE_TYPES
Attributes
Public Class Methods
Source
# 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
Source
# File lib/jmespath/nodes/comparator.rb, line 10 def initialize(left, right) @left = left @right = right end
Public Instance Methods
Source
# File lib/jmespath/nodes/comparator.rb, line 33 def optimize self.class.new(@left.optimize, @right.optimize) end
Source
# File lib/jmespath/nodes/comparator.rb, line 29 def visit(value) check(@left.visit(value), @right.visit(value)) end
Private Instance Methods
Source
# File lib/jmespath/nodes/comparator.rb, line 39 def check(_left_value, _right_value) nil end
Source
# File lib/jmespath/nodes/comparator.rb, line 43 def comparable?(left_value, right_value) COMPARABLE_TYPES.any? do |type| left_value.is_a?(type) && right_value.is_a?(type) end end