lib/csl/node.rb in csl-1.0.0.pre11 vs lib/csl/node.rb in csl-1.0.0.pre12
- old
+ new
@@ -181,18 +181,24 @@
# @overload values_at(selector, ... )
# Returns an array containing the attributes in self according
# to the given selector(s). The selectors may be either integer
# indices, ranges (functionality inherited from Struct) or
- # symbols idenifying valid keys (similar to Hash#values_at).
+ # symbols identifying valid keys (similar to Hash#values_at).
#
# @example
# attributes.values_at(:family, :nick) #=> ['Matsumoto', 'Matz']
#
# @see Struct#values_at
# @return [Array] the list of values
def values_at(*arguments)
- super(*arguments.flatten.map { |k| k.is_a?(Symbol) ? keys.index(k) : k })
+ arguments.flatten.inject([]) do |values, key|
+ if key.is_a?(Symbol)
+ values.push fetch(key)
+ else
+ values.concat super(key)
+ end
+ end
end
})
end
\ No newline at end of file