Sha256: 553b0f70709b008ca1d5eb9d0125136554c4106e36657c0dae2c745af993a868
Contents?: true
Size: 546 Bytes
Versions: 4
Compression:
Stored size: 546 Bytes
Contents
require_relative 'instrument' module Metrics module Instruments class Gauge < Instrument attr_reader :units def initialize(options = {}, &block) raise ArgumentError, "a block is required" unless block_given? @block = block @units = options[:units] end def get instance_exec(&@block) end def as_json(*_) value = get value.respond_to?(:as_json) ? value.as_json : value end def to_json(*_) as_json.to_json end end end end
Version data entries
4 entries across 4 versions & 1 rubygems