Class: Enumpath::Operator::RecursiveDescent
- Defined in:
- lib/enumpath/operator/recursive_descent.rb
Overview
Implements JSONPath recursive descent operator syntax. See README for syntax and examples
Constant Summary collapse
- OPERATOR =
'..'
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.detect?(operator) ⇒ true, false
Simple test of whether the operator matches the OPERATOR constant.
Instance Method Summary collapse
-
#apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object
Yields to the block once for the enumerable itself, and once for every direct member of the enumerable that is also an enumerable.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Enumpath::Operator::Base
Class Method Details
Instance Method Details
#apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object
Yields to the block once for the enumerable itself, and once for every direct member of the enumerable that is also an enumerable
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/enumpath/operator/recursive_descent.rb', line 31 def apply(remaining_path, enum, resolved_path) Enumpath.log('Applying remaining path recursively to enum') { { 'remaining path': remaining_path } } yield(remaining_path, enum, resolved_path) keys(enum).each do |key| value = Enumpath::Resolver::Simple.resolve(key, enum) next unless recursable?(value) Enumpath.log('Applying remaining path recursively to key') do { key: key, 'remaining path': ['..'] + remaining_path } end yield(['..'] + remaining_path, value, resolved_path + [key]) end end |