Sha256: d927e2b466aa8a621bebbd8ca622e88d6d2162e03e4ce2b1396022fba6b89ce0
Contents?: true
Size: 997 Bytes
Versions: 9
Compression:
Stored size: 997 Bytes
Contents
module Hike class NormalizedArray < Array def initialize super() end def []=(*args) value = args.pop if value.respond_to?(:to_ary) value = normalize_elements(value) else value = normalize_element(value) end super(*args.concat([value])) end def <<(element) super normalize_element(element) end def collect! super do |element| result = yield element normalize_element(result) end end alias_method :map!, :collect! def insert(index, *elements) super index, *normalize_elements(elements) end def push(*elements) super(*normalize_elements(elements)) end def replace(elements) super normalize_elements(elements) end def unshift(*elements) super(*normalize_elements(elements)) end def normalize_elements(elements) elements.map do |element| normalize_element(element) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems