Class: Camayoc::Stats
- Inherits:
-
Object
- Object
- Camayoc::Stats
- Defined in:
- lib/camayoc/stats.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
Returns the value of attribute handlers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #<<(handler) ⇒ Object
- #add(handler, filter_opts = {}) ⇒ Object
- #count(stat, value, options = {}) ⇒ Object
- #decrement(stat, options = {}) ⇒ Object
- #increment(stat, options = {}) ⇒ Object
-
#initialize(name, parent = nil) ⇒ Stats
constructor
A new instance of Stats.
- #timing(stat, ms, options = {}) ⇒ Object
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
#handlers ⇒ Object
Returns the value of attribute handlers.
4 5 6 |
# File 'lib/camayoc/stats.rb', line 4 def handlers @handlers end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/camayoc/stats.rb', line 4 def name @name end |
#parent ⇒ Object
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,={}) count_event(StatEvent.new(name,stat,value,)) end |
#decrement(stat, options = {}) ⇒ Object
28 29 30 |
# File 'lib/camayoc/stats.rb', line 28 def decrement(stat,={}) count(stat,-1,) end |
#increment(stat, options = {}) ⇒ Object
24 25 26 |
# File 'lib/camayoc/stats.rb', line 24 def increment(stat,={}) count(stat,1,) end |