Class: PulseMeter::Sensor::Multi
- Includes:
- Enumerable, Mixins::Utils
- Defined in:
- lib/pulse-meter/sensor/multi.rb
Constant Summary
Constants included from Mixins::Dumper
Mixins::Dumper::DUMP_REDIS_KEY
Instance Attribute Summary collapse
-
#configuration_options ⇒ Object
readonly
Returns the value of attribute configuration_options.
-
#factors ⇒ Object
readonly
Returns the value of attribute factors.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sensors ⇒ Object
readonly
Returns the value of attribute sensors.
Attributes inherited from Base
Instance Method Summary collapse
- #each ⇒ Object
- #event(factors_hash, value) ⇒ Object
-
#initialize(name, options) ⇒ Multi
constructor
TODO restore in initializer.
- #sensor(name) ⇒ Object
- #sensor_for_factors(factor_names, factor_values) ⇒ Object
Methods included from Enumerable
Methods included from Mixins::Utils
#assert_array!, #assert_positive_integer!, #assert_ranged_float!, #camelize, #camelize_keys, #constantize, #each_subset, #subsets_of, #symbolize_keys, #titleize, #uniqid
Methods inherited from Base
#annotate, #annotation, #cleanup
Methods included from Mixins::Dumper
Constructor Details
#initialize(name, options) ⇒ Multi
TODO restore in initializer
14 15 16 17 18 19 20 |
# File 'lib/pulse-meter/sensor/multi.rb', line 14 def initialize(name, ) @name = name @factors = assert_array!(, :factors) @sensors = PulseMeter::Sensor::Configuration.new @configuration_options = [:configuration] raise ArgumentError, "configuration option missing" unless @configuration_options end |
Instance Attribute Details
#configuration_options ⇒ Object (readonly)
Returns the value of attribute configuration_options.
10 11 12 |
# File 'lib/pulse-meter/sensor/multi.rb', line 10 def @configuration_options end |
#factors ⇒ Object (readonly)
Returns the value of attribute factors.
8 9 10 |
# File 'lib/pulse-meter/sensor/multi.rb', line 8 def factors @factors end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/pulse-meter/sensor/multi.rb', line 7 def name @name end |
#sensors ⇒ Object (readonly)
Returns the value of attribute sensors.
9 10 11 |
# File 'lib/pulse-meter/sensor/multi.rb', line 9 def sensors @sensors end |
Instance Method Details
#each ⇒ Object
36 37 38 |
# File 'lib/pulse-meter/sensor/multi.rb', line 36 def each sensors.each {|s| yield(s)} end |
#event(factors_hash, value) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/pulse-meter/sensor/multi.rb', line 26 def event(factors_hash, value) ensure_valid_factors!(factors_hash) each_factors_combination do |combination| factor_values = factor_values_for_combination(combination, factors_hash) sensor = get_or_create_sensor(combination, factor_values) sensor.event(value) end end |
#sensor(name) ⇒ Object
22 23 24 |
# File 'lib/pulse-meter/sensor/multi.rb', line 22 def sensor(name) sensors.sensor(name) end |
#sensor_for_factors(factor_names, factor_values) ⇒ Object
40 41 42 43 44 |
# File 'lib/pulse-meter/sensor/multi.rb', line 40 def sensor_for_factors(factor_names, factor_values) sensor( get_sensor_name(factor_names, factor_values) ) end |