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

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/webmock-1.8.11/lib/webmock/util/hash_counter.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/webmock-1.8.11/lib/webmock/util/hash_counter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/webmock-1.8.11/lib/webmock/util/hash_counter.rb
simple-client-0.0.3 vendor/bundle/ruby/1.9.1/gems/webmock-1.8.8/lib/webmock/util/hash_counter.rb
webmock-1.9.0 lib/webmock/util/hash_counter.rb
webmock-1.8.11 lib/webmock/util/hash_counter.rb
webmock-1.8.10 lib/webmock/util/hash_counter.rb
webmock-1.8.9 lib/webmock/util/hash_counter.rb
simple-client-0.0.2 vendor/bundle/ruby/1.8/gems/webmock-1.8.8/lib/webmock/util/hash_counter.rb
webmock-1.8.8 lib/webmock/util/hash_counter.rb
webmock-1.8.7 lib/webmock/util/hash_counter.rb
webmock-1.8.6 lib/webmock/util/hash_counter.rb
webmock-1.8.5 lib/webmock/util/hash_counter.rb
webmock-1.8.4 lib/webmock/util/hash_counter.rb
webmock-1.8.3 lib/webmock/util/hash_counter.rb
webmock-1.8.2 lib/webmock/util/hash_counter.rb
webmock-1.8.1 lib/webmock/util/hash_counter.rb
webmock-1.8.0 lib/webmock/util/hash_counter.rb
webmock-1.7.10 lib/webmock/util/hash_counter.rb
webmock-1.7.8 lib/webmock/util/hash_counter.rb