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?
101
102
103
104
105
|
# File 'lib/json_p3/segment.rb', line 101
def ==(other)
self.class == other.class &&
@selectors == other.selectors &&
@token == other.token
end
|
#hash ⇒ Object
109
110
111
|
# File 'lib/json_p3/segment.rb', line 109
def hash
["..", @selectors, @token].hash
end
|
#resolve(nodes) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/json_p3/segment.rb', line 71
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
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/json_p3/segment.rb', line 83
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
97
98
99
|
# File 'lib/json_p3/segment.rb', line 97
def to_s
"..[#{@selectors.map(&:to_s).join(", ")}]"
end
|