Class: PulseMeter::Sensor::Indicator

Inherits:
Base
  • Object
show all
Defined in:
lib/pulse_meter/sensor/indicator.rb

Overview

Static indicator. In fact is is just a named variable with float value

Direct Known Subclasses

HashedIndicator

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 Base

#annotate, #annotation, #command_aggregator, #event, #initialize

Methods included from Mixins::Dumper

included

Constructor Details

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

Instance Method Details

#cleanupObject

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

#valueFixnum

Get indicator value

Returns:

  • (Fixnum)

    indicator value or zero unless it was initialized



14
15
16
17
# File 'lib/pulse_meter/sensor/indicator.rb', line 14

def value
  val = redis.get(value_key)
  val.nil? ? 0 : val.to_f
end

#value_keyString

Gets redis key by which counter value is stored

Returns:

  • (String)


21
22
23
# File 'lib/pulse_meter/sensor/indicator.rb', line 21

def value_key
  @value_key ||= "pulse_meter:value:#{name}"
end