Class: Matey::VisitsByDayOfWeekComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Matey::VisitsByDayOfWeekComponent
- Defined in:
- app/components/matey/visits_by_day_of_week_component.rb
Instance Method Summary collapse
-
#initialize(visits:, time_window: 1.month, exclude_days: [], color_scheme: "neutral") ⇒ VisitsByDayOfWeekComponent
constructor
A new instance of VisitsByDayOfWeekComponent.
-
#visits_by_day_of_week ⇒ Object
group visits by day in provided time window.
Methods inherited from ApplicationComponent
Methods included from ColorSchemeHelper
Constructor Details
#initialize(visits:, time_window: 1.month, exclude_days: [], color_scheme: "neutral") ⇒ VisitsByDayOfWeekComponent
Returns a new instance of VisitsByDayOfWeekComponent.
5 6 7 8 9 10 |
# File 'app/components/matey/visits_by_day_of_week_component.rb', line 5 def initialize(visits:, time_window: 1.month, exclude_days: [], color_scheme: "neutral") @visits = visits @time_window = time_window @exclude_days = exclude_days @color_scheme = color_scheme(scheme: color_scheme) end |
Instance Method Details
#visits_by_day_of_week ⇒ Object
group visits by day in provided time window
13 14 15 16 |
# File 'app/components/matey/visits_by_day_of_week_component.rb', line 13 def visits_by_day_of_week visits_by_day_of_week = @visits.group_by_day_of_week(:started_at, format: "%A", range: @time_window.ago..).count visits_by_day_of_week.except!(*@exclude_days) if @exclude_days.any? end |