Class: Trashed::Meter
- Inherits:
-
Object
- Object
- Trashed::Meter
- Defined in:
- lib/trashed/meter.rb
Instance Attribute Summary collapse
-
#counters ⇒ Object
readonly
Returns the value of attribute counters.
-
#gauges(name, &block) ⇒ Object
readonly
Returns the value of attribute gauges.
Instance Method Summary collapse
- #count ⇒ Object
- #counts(name, &block) ⇒ Object
- #gauge ⇒ Object
-
#initialize(&block) ⇒ Meter
constructor
A new instance of Meter.
- #instrument ⇒ Object
Constructor Details
#initialize(&block) ⇒ Meter
Returns a new instance of Meter.
5 6 7 8 |
# File 'lib/trashed/meter.rb', line 5 def initialize(&block) @counters, @gauges = {}, {} instance_eval(&block) if block_given? end |
Instance Attribute Details
#counters ⇒ Object (readonly)
Returns the value of attribute counters.
3 4 5 |
# File 'lib/trashed/meter.rb', line 3 def counters @counters end |
#gauges(name, &block) ⇒ Object (readonly)
Returns the value of attribute gauges.
3 4 5 |
# File 'lib/trashed/meter.rb', line 3 def gauges @gauges end |
Instance Method Details
#count ⇒ Object
11 |
# File 'lib/trashed/meter.rb', line 11 def count; read @counters end |
#counts(name, &block) ⇒ Object
10 |
# File 'lib/trashed/meter.rb', line 10 def counts(name, &block) @counters[name] = block end |
#gauge ⇒ Object
14 |
# File 'lib/trashed/meter.rb', line 14 def gauge; read @gauges end |
#instrument ⇒ Object
16 17 18 19 20 |
# File 'lib/trashed/meter.rb', line 16 def instrument before = count yield delta before, count end |