Class: DataSet::HourlyDataSet

Inherits:
DataSet
  • Object
show all
Defined in:
lib/data_set/hourly_data_set.rb

Instance Attribute Summary

Attributes inherited from DataSet

#count, #datapoints, #max_date, #max_value, #min_date, #min_value

Instance Method Summary collapse

Methods inherited from DataSet

#value_for_date, #values, #values_for_google_chart

Constructor Details

#initialize(point_array, count = 24) ⇒ HourlyDataSet

Returns a new instance of HourlyDataSet.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/data_set/hourly_data_set.rb', line 3

def initialize( point_array, count = 24 )

  @datapoints ||= {} #[["2008-06-01 12", 200.58], ["2008-06-02 13", 205.39]]
  @count = count
  
  point_array.each do |date, value|
    value = value.to_f
    @datapoints[date.to_s] = value
  end

  fill_with_zeroes(@count)
  trim_to_limit
end

Instance Method Details

#datesObject

Array of dates corresponding to datapoints in “2009-11-18” format



18
19
20
# File 'lib/data_set/hourly_data_set.rb', line 18

def dates
  @datapoints.collect{|point| point[0]}
end