Class: TempoIQ::Row
- Inherits:
-
Object
- Object
- TempoIQ::Row
- Defined in:
- lib/tempoiq/models/row.rb
Overview
Represents all the data found at a single timestamp.
The hierarchy looks like:
-
timestamp
-
device_key
-
sensor_key => value
-
-
Instance Attribute Summary collapse
-
#ts ⇒ Object
readonly
Timestamp of the row.
-
#values ⇒ Object
readonly
Data at the timestamp [Hash].
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ts, values) ⇒ Row
constructor
A new instance of Row.
-
#value(device_key, key) ⇒ Object
Convenience method to select a single (device, sensor) value from within the row.
Constructor Details
#initialize(ts, values) ⇒ Row
Returns a new instance of Row.
17 18 19 20 |
# File 'lib/tempoiq/models/row.rb', line 17 def initialize(ts, values) @ts = ts @values = values end |
Instance Attribute Details
#ts ⇒ Object (readonly)
Timestamp of the row
10 11 12 |
# File 'lib/tempoiq/models/row.rb', line 10 def ts @ts end |
#values ⇒ Object (readonly)
Data at the timestamp [Hash]
Looks like: => {“sensor1” => 1.23, “sensor2” => 2.34}
15 16 17 |
# File 'lib/tempoiq/models/row.rb', line 15 def values @values end |
Class Method Details
.from_hash(hash) ⇒ Object
22 23 24 |
# File 'lib/tempoiq/models/row.rb', line 22 def self.from_hash(hash) new(hash['t'], hash['data']) end |
Instance Method Details
#value(device_key, key) ⇒ Object
Convenience method to select a single (device, sensor) value from within the row.
28 29 30 |
# File 'lib/tempoiq/models/row.rb', line 28 def value(device_key, key) @values[device_key][key] end |