Class: TempoIQ::DataPoint
- Inherits:
-
Object
- Object
- TempoIQ::DataPoint
- Defined in:
- lib/tempoiq/models/datapoint.rb
Overview
The core type of TempoIQ. Holds a timestamp and value.
Instance Attribute Summary collapse
-
#ts ⇒ Object
readonly
The timestamp of the datapoint [Time].
-
#value ⇒ Object
readonly
The value of the datapoint [Fixnum / Float].
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ts, value) ⇒ DataPoint
constructor
A new instance of DataPoint.
- #to_hash ⇒ Object
Constructor Details
#initialize(ts, value) ⇒ DataPoint
Returns a new instance of DataPoint.
12 13 14 15 |
# File 'lib/tempoiq/models/datapoint.rb', line 12 def initialize(ts, value) @ts = ts @value = value end |
Instance Attribute Details
#ts ⇒ Object (readonly)
The timestamp of the datapoint [Time]
7 8 9 |
# File 'lib/tempoiq/models/datapoint.rb', line 7 def ts @ts end |
#value ⇒ Object (readonly)
The value of the datapoint [Fixnum / Float]
10 11 12 |
# File 'lib/tempoiq/models/datapoint.rb', line 10 def value @value end |
Class Method Details
.from_hash(hash) ⇒ Object
24 25 26 |
# File 'lib/tempoiq/models/datapoint.rb', line 24 def self.from_hash(hash) new(Time.parse(hash['t']), m['v']) end |
Instance Method Details
#to_hash ⇒ Object
17 18 19 20 21 22 |
# File 'lib/tempoiq/models/datapoint.rb', line 17 def to_hash { 't' => ts.iso8601(3), 'v' => value } end |