Sha256: 2b9694a8d15947a75ffa9d57c7cdf5f5cb4e758009136e94fefc9b58e2188e1c
Contents?: true
Size: 961 Bytes
Versions: 1
Compression:
Stored size: 961 Bytes
Contents
module Ykutils class Hasharray < Hash def initialize( *args ) super( *args ) @ary = super.keys # @ary ||= [] unless @ary @ary = [] end end def []=(key,value) super(key,value) unless @ary.index(key) @ary << key end end def each(&block) @ary.each do |it| block.call( it, self[it] ) end end def keys @ary end def values @ary.collect{ |it| self[it] } end def clear super @ary = [] end def replace( *args ) super( *args ) @ary = super.keys unless @ary @ary = [] end end def delete(ind , &block) @ary.delete(ind) super end def delete_if(&block) @ary.each do |it| if block.call( it , self[it] ) @ary.delete(it) end end super end def reject(&block) super end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ykutils-0.1.0 | lib/ykutils/hasharray.rb |