Class: Sufia::Statistics::OverTime
- Inherits:
-
Object
- Object
- Sufia::Statistics::OverTime
- Defined in:
- app/services/sufia/statistics/over_time.rb
Overview
An abstract class for generating cumulative graphs you must provide a ‘relation` method in the concrete class
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(delta_x: 7, x_min: 1.month.ago.beginning_of_day, x_max: Time.zone.now.end_of_day) ⇒ OverTime
constructor
A new instance of OverTime.
- #points ⇒ Object
Constructor Details
#initialize(delta_x: 7, x_min: 1.month.ago.beginning_of_day, x_max: Time.zone.now.end_of_day) ⇒ OverTime
Returns a new instance of OverTime.
9 10 11 12 13 |
# File 'app/services/sufia/statistics/over_time.rb', line 9 def initialize(delta_x: 7, x_min: 1.month.ago.beginning_of_day, x_max: Time.zone.now.end_of_day) @delta_x = delta_x @x_min = x_min @x_max = x_max end |
Instance Method Details
#points ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/services/sufia/statistics/over_time.rb', line 15 def points Enumerator.new(size) do |y| x = @x_min while x <= @x_max x += @delta_x.days y.yield [x.to_i * 1000, point(@x_min, x)] end end end |