Class: Metrics::Instruments::Counter
- Inherits:
-
Object
- Object
- Metrics::Instruments::Counter
- Defined in:
- lib/ruby-metrics/instruments/counter.rb
Instance Attribute Summary collapse
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Instance Method Summary collapse
- #as_json(*_) ⇒ Object
- #clear ⇒ Object
- #dec(value = 1) ⇒ Object (also: #decr)
- #inc(value = 1) ⇒ Object (also: #incr)
-
#initialize(options = {}) ⇒ Counter
constructor
A new instance of Counter.
- #to_i ⇒ Object
- #to_json(*_) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Counter
Returns a new instance of Counter.
7 8 9 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 7 def initialize( = {}) @value = 0 end |
Instance Attribute Details
#units ⇒ Object (readonly)
Returns the value of attribute units.
5 6 7 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 5 def units @units end |
Instance Method Details
#as_json(*_) ⇒ Object
33 34 35 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 33 def as_json(*_) @value end |
#clear ⇒ Object
21 22 23 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 21 def clear @value = 0 end |
#dec(value = 1) ⇒ Object Also known as: decr
16 17 18 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 16 def dec(value = 1) @value -= value end |
#inc(value = 1) ⇒ Object Also known as: incr
11 12 13 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 11 def inc(value = 1) @value += value end |
#to_i ⇒ Object
25 26 27 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 25 def to_i @value.to_i end |
#to_json(*_) ⇒ Object
37 38 39 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 37 def to_json(*_) as_json.to_json end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 29 def to_s @value.to_s end |