Class: Sensor::Payload
- Inherits:
-
Object
- Object
- Sensor::Payload
- Defined in:
- lib/sensor/payload.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#time_range ⇒ Object
readonly
Returns the value of attribute time_range.
Instance Method Summary collapse
- #acquire ⇒ Object
- #distribute ⇒ Object
- #end_date ⇒ Object
-
#initialize(time_range) ⇒ Payload
constructor
A new instance of Payload.
- #start_date ⇒ Object
Constructor Details
#initialize(time_range) ⇒ Payload
Returns a new instance of Payload.
13 14 15 16 |
# File 'lib/sensor/payload.rb', line 13 def initialize(time_range) @time_range = time_range @data = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/sensor/payload.rb', line 11 def data @data end |
#time_range ⇒ Object (readonly)
Returns the value of attribute time_range.
11 12 13 |
# File 'lib/sensor/payload.rb', line 11 def time_range @time_range end |
Instance Method Details
#acquire ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/sensor/payload.rb', line 18 def acquire actuator_classes.each do |actuator| @data.merge!(actuator.new(@time_range).acquire) end @data end |
#distribute ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/sensor/payload.rb', line 26 def distribute if ENV['SLACK_WEBHOOK_URL'] Sensor::OutputDistribution::Slack.new(self).distribute else Sensor::OutputDistribution::FlowDock.new(self).distribute end end |
#end_date ⇒ Object
38 39 40 |
# File 'lib/sensor/payload.rb', line 38 def end_date @time_range.end_date end |
#start_date ⇒ Object
34 35 36 |
# File 'lib/sensor/payload.rb', line 34 def start_date @time_range.start_date end |