Class: JSONPath::Nodes::PathNode
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- JSONPath::Nodes::PathNode
show all
- Defined in:
- lib/jsonpath/nodes.rb
Instance Method Summary
collapse
Instance Method Details
#recurse(obj, &block) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/jsonpath/nodes.rb', line 29
def recurse(obj, &block)
block.call(obj)
children = case obj
when Hash
obj.values
when Array
obj
else
return
end
children.each do |child|
recurse(child, &block)
end
end
|
#traverse(obj, &block) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/jsonpath/nodes.rb', line 19
def traverse(obj, &block)
if !respond_to?(:lower) || lower.text_value == '.'
obj.each(&block)
elsif lower.text_value == '..'
obj.each do |o|
recurse(o, &block)
end
end
end
|
#traversing_descendants? ⇒ Boolean
15
16
17
|
# File 'lib/jsonpath/nodes.rb', line 15
def traversing_descendants?
respond_to?(:lower) && lower.text_value == '..'
end
|