Class: Enumpath::Operator::Child
- Defined in:
 - lib/enumpath/operator/child.rb
 
Overview
Implements JSONPath child operator syntax. See README for syntax and examples.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- 
  
    
      .detect?(operator, enum)  ⇒ true, false 
    
    
  
  
  
  
  
  
  
  
  
    
Checks to see if an operator is valid as a child operator.
 
Instance Method Summary collapse
- 
  
    
      #apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Resolves a child operator against an enumerable.
 
Methods inherited from Base
Constructor Details
This class inherits a constructor from Enumpath::Operator::Base
Class Method Details
.detect?(operator, enum) ⇒ true, false
Checks to see if an operator is valid as a child operator. It is considered valid if the enumerable contains an index, key, member, or property that responds to child.
      13 14 15 16  | 
    
      # File 'lib/enumpath/operator/child.rb', line 13 def detect?(operator, enum) !Enumpath::Resolver::Simple.resolve(operator, enum).nil? || !Enumpath::Resolver::Property.resolve(operator, enum).nil? end  | 
  
Instance Method Details
#apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object
Resolves a child operator against an enumerable. If the child operator matches a index, key, member, or property of the enumerable it is yielded to the block.
      27 28 29 30 31  | 
    
      # File 'lib/enumpath/operator/child.rb', line 27 def apply(remaining_path, enum, resolved_path) value = Enumpath::Resolver::Simple.resolve(operator, enum) value = Enumpath::Resolver::Property.resolve(operator, enum) if value.nil? yield(remaining_path, value, resolved_path + [operator]) unless value.nil? end  |