Class: JSONP3::Path::DescendantSegment
- Inherits:
-
Segment
- Object
- Segment
- JSONP3::Path::DescendantSegment
show all
- Defined in:
- lib/json_p3/path/segment.rb
Overview
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?
102
103
104
105
106
|
# File 'lib/json_p3/path/segment.rb', line 102
def ==(other)
self.class == other.class &&
@selectors == other.selectors &&
@token == other.token
end
|
#hash ⇒ Object
110
111
112
|
# File 'lib/json_p3/path/segment.rb', line 110
def hash
["..", @selectors, @token].hash
end
|
#resolve(nodes) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/json_p3/path/segment.rb', line 72
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
|
#resolve_enum(nodes) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/json_p3/path/segment.rb', line 84
def resolve_enum(nodes)
Enumerator.new do |yielder|
nodes.each do |node|
visit_enum(node).each do |descendant|
@selectors.each do |selector|
selector.resolve(descendant).each do |item|
yielder << item
end
end
end
end
end
end
|
#to_s ⇒ Object
98
99
100
|
# File 'lib/json_p3/path/segment.rb', line 98
def to_s
"..[#{@selectors.join(", ")}]"
end
|