Class: PulseMeter::Sensor::UniqCounter

Inherits:
Counter show all
Defined in:
lib/pulse-meter/sensor/uniq_counter.rb

Constant Summary

Constants included from Mixins::Dumper

Mixins::Dumper::DUMP_REDIS_KEY

Instance Attribute Summary

Attributes inherited from Base

#name, #redis

Instance Method Summary collapse

Methods inherited from Counter

#cleanup, #incr, #value_key

Methods inherited from Base

#annotate, #annotation, #cleanup, #initialize

Methods included from Mixins::Dumper

included

Constructor Details

This class inherits a constructor from PulseMeter::Sensor::Base

Instance Method Details

#event(name) ⇒ Object

Processes event

Parameters:

  • name (String)

    value to be counted



10
11
12
# File 'lib/pulse-meter/sensor/uniq_counter.rb', line 10

def event(name)
  redis.sadd(value_key, name)
end

#valueFixnum

Returs number of unique values ever sent to counter

Returns:

  • (Fixnum)


16
17
18
# File 'lib/pulse-meter/sensor/uniq_counter.rb', line 16

def value
  redis.scard(value_key)
end