Class: JMESPath::Nodes::Comparator Private
- 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.
Direct Known Subclasses
JMESPath::Nodes::Comparators::Eq, JMESPath::Nodes::Comparators::Gt, JMESPath::Nodes::Comparators::Gte, JMESPath::Nodes::Comparators::Lt, JMESPath::Nodes::Comparators::Lte, JMESPath::Nodes::Comparators::Neq
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
- #left ⇒ Object readonly private
- #right ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(left, right) ⇒ Comparator
constructor
private
A new instance of Comparator.
- #optimize ⇒ Object private
- #visit(value) ⇒ Object private
Methods inherited from Node
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
#left ⇒ Object (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 |
#right ⇒ Object (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
#optimize ⇒ 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.
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 |