Parent

Methods

Class/Module Index [+]

Quicksearch

WebMock::Util::WebMock::Util::Util::HashCounter

Attributes

hash[RW]

Public Class Methods

new() click to toggle source
# File lib/webmock/util/hash_counter.rb, line 5
def initialize
  self.hash = {}
  @order = {}
  @max = 0
end

Public Instance Methods

each(&block) click to toggle source
# File lib/webmock/util/hash_counter.rb, line 18
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
get(key) click to toggle source
# File lib/webmock/util/hash_counter.rb, line 14
def get key
  hash[key] || 0
end
put(key, num=1) click to toggle source
# File lib/webmock/util/hash_counter.rb, line 10
def put key, num=1
  hash[key] = (hash[key] || 0) + num
  @order[key] = @max = @max + 1
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.