Class: JSONPath::Nodes::ExprNode

Inherits:
CodeNode
  • Object
show all
Defined in:
lib/jsonpath/nodes.rb

Instance Method Summary collapse

Methods inherited from CodeNode

#code, #execute

Methods inherited from PathNode

#recurse, #traverse, #traversing_descendants?

Instance Method Details

#descend(*objects) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/jsonpath/nodes.rb', line 172

def descend(*objects)
  results = []
  traverse(objects) do |obj|
    res = execute(obj)
    case obj
    when Hash
      next unless obj.key?(res)
    when Array
      next unless obj.size > res
    else
      next
    end
    results << obj[res]
  end
  results
end