Class: JSONP3::WildcardSelector
Overview
The wildcard selector selects all elements from an array or values from a hash.
Instance Attribute Summary
Attributes inherited from Selector
#token
Instance Method Summary
collapse
Methods inherited from Selector
#initialize, #singular?
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
152
153
154
|
# File 'lib/json_p3/selector.rb', line 152
def ==(other)
self.class == other.class && @token == other.token
end
|
#hash ⇒ Object
158
159
160
|
# File 'lib/json_p3/selector.rb', line 158
def hash
@token.hash
end
|
#resolve(node) ⇒ Object
138
139
140
141
142
143
144
145
146
|
# File 'lib/json_p3/selector.rb', line 138
def resolve(node)
if node.value.is_a? Hash
node.value.map { |k, v| node.new_child(v, k) }
elsif node.value.is_a? Array
node.value.map.with_index { |e, i| node.new_child(e, i) }
else
[]
end
end
|
#to_s ⇒ Object
148
149
150
|
# File 'lib/json_p3/selector.rb', line 148
def to_s
"*"
end
|