Class: TempoIQ::DataPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/tempoiq/models/datapoint.rb

Overview

The core type of TempoIQ. Holds a timestamp and value.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#tsObject (readonly)

The timestamp of the datapoint [Time]



7
8
9
# File 'lib/tempoiq/models/datapoint.rb', line 7

def ts
  @ts
end

#valueObject (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_hashObject



17
18
19
20
21
22
# File 'lib/tempoiq/models/datapoint.rb', line 17

def to_hash
  {
    't' => ts.iso8601(3),
    'v' => value
  }
end