Class: DataSet::HourOfDayDataSet

Inherits:
DataSet
  • Object
show all
Defined in:
lib/data_set/hour_of_day_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

#dates, #value_for_date, #values_for_google_chart

Constructor Details

#initialize(point_array) ⇒ HourOfDayDataSet

Returns a new instance of HourOfDayDataSet.



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

def initialize( point_array )
  @datapoints = {}
  hours.each do |hour|
    @datapoints[hour] = 0
  end
  
  point_array.each do |hour_of_day, value|
    value = value.to_f
    @datapoints[hour_of_day.to_i] = value
  end

  @datapoints = @datapoints.sort
end

Instance Method Details

#hoursObject



17
18
19
# File 'lib/data_set/hour_of_day_data_set.rb', line 17

def hours
  (0..23)
end

#valuesObject



21
22
23
# File 'lib/data_set/hour_of_day_data_set.rb', line 21

def values
  hours.collect{|hour| @datapoints[hour][1]}
end