Class: DataSet::DayOfWeekDataSet

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

Returns a new instance of DayOfWeekDataSet.



3
4
5
6
7
8
9
10
# File 'lib/data_set/day_of_week_data_set.rb', line 3

def initialize( point_array )
  @datapoints ||= {'Mon'=>0, 'Tue'=>0, 'Wed'=> 0, 'Thu'=>0, 'Fri'=>0, 'Sat'=>0, 'Sun'=>0}
 
  point_array.each do |day_of_week, value|
    value = value.to_f
    @datapoints[day_of_week] = value
  end
end

Instance Method Details

#daysObject



12
13
14
# File 'lib/data_set/day_of_week_data_set.rb', line 12

def days
  %w{Mon Tue Wed Thu Fri Sat Sun}
end

#valuesObject



16
17
18
19
20
21
22
23
24
# File 'lib/data_set/day_of_week_data_set.rb', line 16

def values
  [ @datapoints['Mon'],
    @datapoints['Tue'],
    @datapoints['Wed'],
    @datapoints['Thu'],
    @datapoints['Fri'],
    @datapoints['Sat'],
    @datapoints['Sun']]
end