Sha256: 9a687144c43663dede41a21697f0dac87b7609255bdc6eeb7dfe99c1def39c56
Contents?: true
Size: 852 Bytes
Versions: 5
Compression:
Stored size: 852 Bytes
Contents
module Ykutils class Hasharray < Hash def initialize(*args) super(*args) @ary = super.keys # @ary ||= [] @ary ||= [] end def []=(key, value) super(key, value) @ary << key unless @ary.index(key) 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 @ary ||= [] end def delete(ind, &block) @ary.delete(ind) super end def delete_if(&block) @ary.each do |it| @ary.delete(it) if block.call(it, self[it]) end super end def reject(&block) super end end end
Version data entries
5 entries across 5 versions & 1 rubygems