Class: PulseMeter::Sensor::Indicator
- Defined in:
- lib/pulse-meter/sensor/indicator.rb
Overview
Static indicator. In fact is is just a named variable with float value
Constant Summary
Constants included from Mixins::Dumper
Mixins::Dumper::DUMP_REDIS_KEY
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#cleanup ⇒ Object
Cleans up all sensor metadata in Redis.
-
#event(value) ⇒ Object
Sets indicator value.
-
#value ⇒ Fixnum
Get indicator value.
-
#value_key ⇒ String
Gets redis key by which counter value is stored.
Methods inherited from Base
#annotate, #annotation, #initialize
Methods included from Mixins::Dumper
Constructor Details
This class inherits a constructor from PulseMeter::Sensor::Base
Instance Method Details
#cleanup ⇒ Object
Cleans up all sensor metadata in Redis
7 8 9 10 |
# File 'lib/pulse-meter/sensor/indicator.rb', line 7 def cleanup redis.del(value_key) super end |
#event(value) ⇒ Object
Sets indicator value
14 15 16 |
# File 'lib/pulse-meter/sensor/indicator.rb', line 14 def event(value) redis.set(value_key, value.to_f) end |
#value ⇒ Fixnum
Get indicator value
20 21 22 23 |
# File 'lib/pulse-meter/sensor/indicator.rb', line 20 def value val = redis.get(value_key) val.nil? ? 0 : val.to_f end |
#value_key ⇒ String
Gets redis key by which counter value is stored
27 28 29 |
# File 'lib/pulse-meter/sensor/indicator.rb', line 27 def value_key @value_key ||= "pulse_meter:value:#{name}" end |