Class: Camayoc::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/camayoc/stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent = nil) ⇒ Stats

Returns a new instance of Stats.



6
7
8
9
10
# File 'lib/camayoc/stats.rb', line 6

def initialize(name,parent=nil)
  self.name = name
  self.parent = parent
  self.handlers = []
end

Instance Attribute Details

#handlersObject

Returns the value of attribute handlers.



4
5
6
# File 'lib/camayoc/stats.rb', line 4

def handlers
  @handlers
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/camayoc/stats.rb', line 4

def name
  @name
end

#parentObject

Returns the value of attribute parent.



4
5
6
# File 'lib/camayoc/stats.rb', line 4

def parent
  @parent
end

Instance Method Details

#<<(handler) ⇒ Object



20
21
22
# File 'lib/camayoc/stats.rb', line 20

def <<(handler)
  self.add(handler)
end

#add(handler, filter_opts = {}) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/camayoc/stats.rb', line 12

def add(handler,filter_opts={})
  if !filter_opts.empty?
    handler = Handlers::Filter.new(handler,filter_opts)
  end
  self.handlers << handler
  self
end

#count(stat, value, options = {}) ⇒ Object



32
33
34
# File 'lib/camayoc/stats.rb', line 32

def count(stat,value,options={})
  count_event(StatEvent.new(name,stat,value,options))
end

#decrement(stat, options = {}) ⇒ Object



28
29
30
# File 'lib/camayoc/stats.rb', line 28

def decrement(stat,options={})
  count(stat,-1,options)
end

#increment(stat, options = {}) ⇒ Object



24
25
26
# File 'lib/camayoc/stats.rb', line 24

def increment(stat,options={})
  count(stat,1,options)  
end

#timing(stat, ms, options = {}) ⇒ Object



36
37
38
# File 'lib/camayoc/stats.rb', line 36

def timing(stat,ms,options={})
  timing_event(StatEvent.new(name,stat,ms,options))
end