Sha256: d72b373c8e05903726bb6ea81609e0287805dec33ead3b12a5fd9bbc7cd20460

Contents?: true

Size: 626 Bytes

Versions: 9

Compression:

Stored size: 626 Bytes

Contents

module PulseMeter
  module Sensor
    # Static hashed indicator. In fact is is just a named hash with float value
    class HashedIndicator < Indicator

      # Get indicator values
      # @return [Fixnum] indicator value or zero unless it was initialized
      def value
        redis.
          hgetall(value_key).
          inject(Hash.new(0)) {|h, (k, v)| h[k] = v.to_f; h}
      end

      private

      # Sets indicator values
      # @param value [Hash] new indicator values
      def process_event(events)
        events.each_pair {|name, value| redis.hset(value_key, name, value.to_f)}
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pulse-meter-0.3.1 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.3.0 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.11 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.10 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.9 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.8 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.7 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.6 lib/pulse-meter/sensor/hashed_indicator.rb
pulse-meter-0.2.5 lib/pulse-meter/sensor/hashed_indicator.rb