Class: DataPoint

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/time_series/data_point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timestamp, data) ⇒ DataPoint

Returns a new instance of DataPoint.



6
7
8
9
# File 'lib/time_series/data_point.rb', line 6

def initialize(timestamp, data)
  timestamp = timestamp.to_time unless timestamp.kind_of? Time
  @timestamp, @data = timestamp, data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/time_series/data_point.rb', line 4

def data
  @data
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



4
5
6
# File 'lib/time_series/data_point.rb', line 4

def timestamp
  @timestamp
end

Instance Method Details

#<=>(another) ⇒ Object



11
12
13
# File 'lib/time_series/data_point.rb', line 11

def <=>(another)
  result = @timestamp <=> another.timestamp
end

#==(another) ⇒ Object



15
16
17
# File 'lib/time_series/data_point.rb', line 15

def ==(another)
  @timestamp == another.timestamp and @data == another.data
end