Class: Drone::Metrics::Gauge

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

Overview

Gauge are linked to a block of code which will be called when the value is asked, the block is expected to return a number

Instance Attribute Summary

Attributes inherited from Drone::Metric

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Gauge

Returns a new instance of Gauge.



13
14
15
16
17
# File 'lib/drone/metrics/gauge.rb', line 13

def initialize(name, &block)
  raise "Block expected" unless block
  super(name)
  @block = block
end

Instance Method Details

#valueObject



19
20
21
# File 'lib/drone/metrics/gauge.rb', line 19

def value
  @block.call()
end