Sha256: f474fabf1500111e87480d8a2a580dfb56d66f930e1768b499794e850db7e73f

Contents?: true

Size: 426 Bytes

Versions: 6

Compression:

Stored size: 426 Bytes

Contents

require 'json'

# Static counter to count unique values
module PulseMeter
  module Sensor
    class UniqCounter < Counter

      # Processes event
      # @param name [String] value to be counted
      def event(name)
        redis.sadd(value_key, name)
      end

      # Returs number of unique values ever sent to counter
      # @return [Fixnum]
      def value
        redis.scard(value_key)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
pulse-meter-0.2.3 lib/pulse-meter/sensor/uniq_counter.rb
pulse-meter-0.2.2 lib/pulse-meter/sensor/uniq_counter.rb
pulse-meter-0.2.1 lib/pulse-meter/sensor/uniq_counter.rb
pulse-meter-0.2.0 lib/pulse-meter/sensor/uniq_counter.rb
pulse-meter-client-backport-0.1.4 lib/pulse-meter/sensor/uniq_counter.rb
pulse-meter-0.1.11 lib/pulse-meter/sensor/uniq_counter.rb