Class: Tailstrom::CounterCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/tailstrom/counter_collection.rb

Instance Method Summary collapse

Constructor Details

#initializeCounterCollection

Returns a new instance of CounterCollection.



5
6
7
# File 'lib/tailstrom/counter_collection.rb', line 5

def initialize
  clear
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/tailstrom/counter_collection.rb', line 13

def [](key)
  @counters[key]
end

#clearObject



9
10
11
# File 'lib/tailstrom/counter_collection.rb', line 9

def clear
  @counters = Hash.new {|h, k| h[k] = Counter.new }
end

#each(&block) ⇒ Object



21
22
23
# File 'lib/tailstrom/counter_collection.rb', line 21

def each(&block)
  @counters.each &block
end

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/tailstrom/counter_collection.rb', line 17

def empty?
  @counters.empty?
end

#keysObject



33
34
35
# File 'lib/tailstrom/counter_collection.rb', line 33

def keys
  @counters.keys
end

#sizeObject



29
30
31
# File 'lib/tailstrom/counter_collection.rb', line 29

def size
  @counters.size
end

#to_aObject



25
26
27
# File 'lib/tailstrom/counter_collection.rb', line 25

def to_a
  @counters.to_a
end