Class: Metrics::Instruments::Gauge
- Inherits:
-
Object
- Object
- Metrics::Instruments::Gauge
- Defined in:
- lib/ruby-metrics/instruments/gauge.rb
Instance Attribute Summary collapse
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Instance Method Summary collapse
- #as_json(*_) ⇒ Object
- #get ⇒ Object
-
#initialize(options = {}, &block) ⇒ Gauge
constructor
A new instance of Gauge.
- #to_json(*_) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Gauge
Returns a new instance of Gauge.
6 7 8 9 10 |
# File 'lib/ruby-metrics/instruments/gauge.rb', line 6 def initialize( = {}, &block) raise ArgumentError, "a block is required" unless block_given? @block = block @units = [:units] end |
Instance Attribute Details
#units ⇒ Object (readonly)
Returns the value of attribute units.
4 5 6 |
# File 'lib/ruby-metrics/instruments/gauge.rb', line 4 def units @units end |
Instance Method Details
#as_json(*_) ⇒ Object
16 17 18 19 |
# File 'lib/ruby-metrics/instruments/gauge.rb', line 16 def as_json(*_) value = get value.respond_to?(:as_json) ? value.as_json : value end |
#get ⇒ Object
12 13 14 |
# File 'lib/ruby-metrics/instruments/gauge.rb', line 12 def get instance_exec(&@block) end |
#to_json(*_) ⇒ Object
21 22 23 |
# File 'lib/ruby-metrics/instruments/gauge.rb', line 21 def to_json(*_) as_json.to_json end |