Class: WeatherLink::SensorData
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- WeatherLink::SensorData
- Defined in:
- lib/weatherlink/sensor_data.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#sensor_data ⇒ Object
readonly
Returns the value of attribute sensor_data.
Instance Method Summary collapse
- #archive? ⇒ Boolean
- #current_conditions? ⇒ Boolean
- #description ⇒ Object
- #health? ⇒ Boolean
-
#initialize(client, sensor_data) ⇒ SensorData
constructor
A new instance of SensorData.
- #inspect ⇒ Object
- #lsid ⇒ Object
- #record_type ⇒ Object
- #sensor ⇒ Object
- #sensor_type ⇒ Object
- #to_s ⇒ Object
- #weather? ⇒ Boolean
Constructor Details
#initialize(client, sensor_data) ⇒ SensorData
Returns a new instance of SensorData.
9 10 11 12 13 14 15 16 |
# File 'lib/weatherlink/sensor_data.rb', line 9 def initialize(client, sensor_data) @client = client @sensor_data = HashWrapper.new(sensor_data) @records = @sensor_data['data'].map do |data| SensorRecord.new(client, client.attach_units(data)) end super(@records.first) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/weatherlink/sensor_data.rb', line 7 def client @client end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/weatherlink/sensor_data.rb', line 7 def records @records end |
#sensor_data ⇒ Object (readonly)
Returns the value of attribute sensor_data.
7 8 9 |
# File 'lib/weatherlink/sensor_data.rb', line 7 def sensor_data @sensor_data end |
Instance Method Details
#archive? ⇒ Boolean
50 51 52 |
# File 'lib/weatherlink/sensor_data.rb', line 50 def archive? record_type.archive? end |
#current_conditions? ⇒ Boolean
46 47 48 |
# File 'lib/weatherlink/sensor_data.rb', line 46 def current_conditions? record_type.current_conditions? end |
#description ⇒ Object
58 59 60 |
# File 'lib/weatherlink/sensor_data.rb', line 58 def description record_type.description end |
#health? ⇒ Boolean
42 43 44 |
# File 'lib/weatherlink/sensor_data.rb', line 42 def health? record_type.health? end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/weatherlink/sensor_data.rb', line 22 def inspect to_s end |
#lsid ⇒ Object
26 27 28 |
# File 'lib/weatherlink/sensor_data.rb', line 26 def lsid sensor_data.lsid end |
#record_type ⇒ Object
38 39 40 |
# File 'lib/weatherlink/sensor_data.rb', line 38 def record_type @record_type ||= client.api.class.record_type(sensor_data.data_structure_type) end |
#sensor ⇒ Object
30 31 32 |
# File 'lib/weatherlink/sensor_data.rb', line 30 def sensor @sensor ||= @client.sensors.select { |sensor| sensor.lsid == lsid }.first end |
#sensor_type ⇒ Object
34 35 36 |
# File 'lib/weatherlink/sensor_data.rb', line 34 def sensor_type sensor_data.sensor_type end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/weatherlink/sensor_data.rb', line 18 def to_s "#<#{self.class.name} lsid=#{lsid} (#{record_type.description}, #{records.size} records)>" end |
#weather? ⇒ Boolean
54 55 56 |
# File 'lib/weatherlink/sensor_data.rb', line 54 def weather? record_type.current_conditions? || record_type.archive? end |