Class: Hyrax::Statistics::OverTime
- Inherits:
-
Object
- Object
- Hyrax::Statistics::OverTime
- Defined in:
- app/services/hyrax/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, x_output: ->(x) { x.to_i * 1000 }) ⇒ 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, x_output: ->(x) { x.to_i * 1000 }) ⇒ OverTime
Returns a new instance of OverTime.
11 12 13 14 15 16 17 18 19 |
# File 'app/services/hyrax/statistics/over_time.rb', line 11 def initialize(delta_x: 7, x_min: 1.month.ago.beginning_of_day, x_max: Time.zone.now.end_of_day, x_output: ->(x) { x.to_i * 1000 }) @delta_x = delta_x @x_min = x_min @x_max = x_max @x_output = x_output end |
Instance Method Details
#points ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/services/hyrax/statistics/over_time.rb', line 21 def points Enumerator.new(size) do |y| x = @x_min while x <= @x_max x += @delta_x.days y.yield [@x_output.call(x), point(@x_min, x)] end end end |