Class: Metrics::Instruments::Counter
- Inherits:
-
Object
- Object
- Metrics::Instruments::Counter
- Defined in:
- lib/ruby-metrics/instruments/counter.rb
Instance Method Summary collapse
- #as_json(*_) ⇒ Object
- #clear ⇒ Object
- #dec(value = 1) ⇒ Object (also: #decr)
- #inc(value = 1) ⇒ Object (also: #incr)
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #to_i ⇒ Object
- #to_json(*_) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
4 5 6 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 4 def initialize @value = 0 end |
Instance Method Details
#as_json(*_) ⇒ Object
30 31 32 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 30 def as_json(*_) @value end |
#clear ⇒ Object
18 19 20 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 18 def clear @value = 0 end |
#dec(value = 1) ⇒ Object Also known as: decr
13 14 15 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 13 def dec(value = 1) @value -= value end |
#inc(value = 1) ⇒ Object Also known as: incr
8 9 10 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 8 def inc(value = 1) @value += value end |
#to_i ⇒ Object
22 23 24 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 22 def to_i @value.to_i end |
#to_json(*_) ⇒ Object
34 35 36 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 34 def to_json(*_) as_json.to_json end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/ruby-metrics/instruments/counter.rb', line 26 def to_s @value.to_s end |