Class: Drone::Metrics::Counter

Inherits:
Drone::Metric show all
Defined in:
lib/drone/metrics/counter.rb

Overview

A Counter store a number which can go up or down, the counter can change a counter value with the methods increment and decrement aliased as inc and dec

Instance Attribute Summary

Attributes inherited from Drone::Metric

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, initial_value = 0) ⇒ Counter

Returns a new instance of Counter.



14
15
16
17
18
# File 'lib/drone/metrics/counter.rb', line 14

def initialize(name, initial_value = 0)
  super(name)
  
  @value = Drone::request_number("#{name}:value", initial_value)
end

Instance Method Details

#clearObject



34
35
36
# File 'lib/drone/metrics/counter.rb', line 34

def clear
  @value.set(0)
end

#decrement(n = 1) ⇒ Object Also known as: dec



29
30
31
# File 'lib/drone/metrics/counter.rb', line 29

def decrement(n = 1)
  @value.dec(n)
end

#increment(n = 1) ⇒ Object Also known as: inc



24
25
26
# File 'lib/drone/metrics/counter.rb', line 24

def increment(n = 1)
  @value.inc(n)
end

#valueObject



20
21
22
# File 'lib/drone/metrics/counter.rb', line 20

def value
  @value.get
end