Class: JMESPath::Nodes::Chain Private
- Inherits:
-
Object
- Object
- JMESPath::Nodes::Chain
- Defined in:
- lib/jmespath/nodes/subexpression.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.
Instance Method Summary collapse
-
#initialize(children) ⇒ Chain
constructor
private
A new instance of Chain.
- #optimize ⇒ Object private
- #visit(value) ⇒ Object private
Constructor Details
#initialize(children) ⇒ Chain
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 Chain.
39 40 41 |
# File 'lib/jmespath/nodes/subexpression.rb', line 39 def initialize(children) @children = children 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.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jmespath/nodes/subexpression.rb', line 49 def optimize children = @children.map(&:optimize) index = 0 while index < children.size - 1 if children[index].chains_with?(children[index + 1]) children[index] = children[index].chain(children[index + 1]) children.delete_at(index + 1) else index += 1 end end Chain.new(children) 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.
43 44 45 46 47 |
# File 'lib/jmespath/nodes/subexpression.rb', line 43 def visit(value) @children.reduce(value) do |v, child| child.visit(v) end end |