Class: DataSet::HourOfDayDataSet
- 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
- #hours ⇒ Object
-
#initialize(point_array) ⇒ HourOfDayDataSet
constructor
A new instance of HourOfDayDataSet.
- #values ⇒ Object
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
#hours ⇒ Object
17 18 19 |
# File 'lib/data_set/hour_of_day_data_set.rb', line 17 def hours (0..23) end |
#values ⇒ Object
21 22 23 |
# File 'lib/data_set/hour_of_day_data_set.rb', line 21 def values hours.collect{|hour| @datapoints[hour][1]} end |