Class: JSONP3::RecursiveDescentSegment
Overview
The recursive descent segment
Instance Attribute Summary
Attributes inherited from Segment
#selectors, #token
Instance Method Summary
collapse
Methods inherited from Segment
#initialize
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
68
69
70
71
72
|
# File 'lib/json_p3/segment.rb', line 68
def ==(other)
self.class == other.class &&
@selectors == other.selectors &&
@token == other.token
end
|
#hash ⇒ Object
76
77
78
|
# File 'lib/json_p3/segment.rb', line 76
def hash
["..", @selectors, @token].hash
end
|
#resolve(nodes) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/json_p3/segment.rb', line 52
def resolve(nodes)
rv = [] nodes.each do |node|
visit(node).each do |descendant|
@selectors.each do |selector|
rv.concat selector.resolve(descendant)
end
end
end
rv
end
|
#to_s ⇒ Object
64
65
66
|
# File 'lib/json_p3/segment.rb', line 64
def to_s
"..[#{@selectors.map(&:to_s).join(", ")}]"
end
|