class JMESPath::Nodes::Comparator
Constants
- COMPARABLE_TYPES
Attributes
left[R]
right[R]
Public Class Methods
create(relation, left, right)
click to toggle source
# File lib/jmespath/nodes/comparator.rb, line 14 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
new(left, right)
click to toggle source
# File lib/jmespath/nodes/comparator.rb, line 9 def initialize(left, right) @left = left @right = right end
Public Instance Methods
optimize()
click to toggle source
# File lib/jmespath/nodes/comparator.rb, line 32 def optimize self.class.new(@left.optimize, @right.optimize) end
visit(value)
click to toggle source
# File lib/jmespath/nodes/comparator.rb, line 28 def visit(value) check(@left.visit(value), @right.visit(value)) end
Private Instance Methods
check(_left_value, _right_value)
click to toggle source
# File lib/jmespath/nodes/comparator.rb, line 38 def check(_left_value, _right_value) nil end
comparable?(left_value, right_value)
click to toggle source
# File lib/jmespath/nodes/comparator.rb, line 42 def comparable?(left_value, right_value) COMPARABLE_TYPES.any? do |type| left_value.is_a?(type) && right_value.is_a?(type) end end