Sha256: cda8c308d776e264336486e475ddf2e65f209e0d4c9e750354a9d224bfd5d7d8
Contents?: true
Size: 504 Bytes
Versions: 33
Compression:
Stored size: 504 Bytes
Contents
module WebMock module Util class Util::HashCounter attr_accessor :hash def initialize self.hash = {} @order = {} @max = 0 end def put key, num=1 hash[key] = (hash[key] || 0) + num @order[key] = @max = @max + 1 end def get key hash[key] || 0 end def each(&block) @order.to_a.sort {|a, b| a[1] <=> b[1]}.each do |a| block.call(a[0], hash[a[0]]) end end end end end
Version data entries
33 entries across 33 versions & 4 rubygems