Sha256: da4c8d6ea5b0b1cfae8dd9737b44754ecf0496e5de66d9dcb791d04b6064d040

Contents?: true

Size: 482 Bytes

Versions: 4

Compression:

Stored size: 482 Bytes

Contents

module Salus
  class Absolute < Metric
    def calc
      super
      @last_calced_value = nil

      if @values.length < STORAGE_DEPTH
        return
      elsif @values[0].expired?(@values[1].timestamp)
        return
      elsif !@values[1].value.is_a?(Numeric)
        return
      end

      @last_calced_value = begin
        dt = (@values[1].timestamp - @values[0].timestamp)
        (dt == 0) ? nil : (@values[1].value / dt)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
salus-0.2.1 lib/salus/metric/absolute.rb
salus-0.2.0 lib/salus/metric/absolute.rb
salus-0.1.3 lib/salus/metric/absolute.rb
salus-0.1.2 lib/salus/metric/absolute.rb