Class: WeatherLink::SensorRecord
Instance Attribute Summary collapse
Attributes inherited from HashWrapper
#data
Instance Method Summary
collapse
Constructor Details
#initialize(client, data) ⇒ SensorRecord
Returns a new instance of SensorRecord.
7
8
9
10
|
# File 'lib/weatherlink/sensor_record.rb', line 7
def initialize(client, data)
@client = client
super(data)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/weatherlink/sensor_record.rb', line 26
def method_missing(symbol, *args)
return Time.at(data[symbol.to_s]) if symbol == :ts || symbol.to_s.end_with?('_at')
return client.convert(symbol, super) if data.include?(symbol.to_s)
super
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/weatherlink/sensor_record.rb', line 5
def client
@client
end
|
Instance Method Details
#inspect ⇒ Object
16
17
18
|
# File 'lib/weatherlink/sensor_record.rb', line 16
def inspect
to_s
end
|
#time ⇒ Object
20
21
22
|
# File 'lib/weatherlink/sensor_record.rb', line 20
def time
Time.at(ts)
end
|
#to_s ⇒ Object
12
13
14
|
# File 'lib/weatherlink/sensor_record.rb', line 12
def to_s
"#<#{self.class.name} time='#{time}' (#{data.size} values)>"
end
|