Sha256: e6049214ee1e07de6a9e637f7ec7aa73e0766f3ac1a56f6767d7b739205346b5

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 Bytes

Contents

class FnordMetric::NumbersWidget < FnordMetric::Widget

  def data
    super.merge(
      :offsets => offsets,
      :gauges => data_gauges
    )
  end

  def data_gauges
    Hash.new.tap do |hash|
      gauges.each do |g|
        hash[g.name] = {
          :values => data_gauge(g),
          :title => g.name
        }
      end
    end
  end

  def data_gauge(gauge)
    offsets.map do |offset|
      offset_time = Time.now.to_i - offset*gauge.tick
      [gauge.tick_at(offset_time), gauge.value_at(offset_time)]
    end
  end

  def has_tick?
    false
  end

  def offsets
    [0, 1, 30]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fnordmetric-0.5.1 lib/fnordmetric/numbers_widget.rb
fnordmetric-0.5.0 lib/fnordmetric/numbers_widget.rb