Class: Pagy::Calendar::Day
- Inherits:
-
Pagy::Calendar
- Object
- Pagy
- Pagy::Calendar
- Pagy::Calendar::Day
- Defined in:
- lib/pagy/calendar.rb
Overview
Calendar day subclass
Constant Summary
Constants inherited from Pagy::Calendar
Constants inherited from Pagy
DEFAULT, ElasticsearchRails, LABEL_PLACEHOLDER, Meilisearch, PAGE_PLACEHOLDER, Searchkick, VERSION
Instance Attribute Summary
Attributes inherited from Pagy::Calendar
#time_order, #utc_from, #utc_to
Attributes inherited from Pagy
#count, #from, #in, #items, #last, #next, #offset, #page, #pages, #params, #prev, #to, #vars
Instance Method Summary collapse
-
#label_for(page, **opts) ⇒ Object
Generate a label for each page (it can pass along the I18n gem opts when it’s used with the i18n extra).
-
#setup_unit_vars ⇒ Object
Setup the calendar vars when the unit is :day.
Methods inherited from Pagy::Calendar
create, #current_unit_minmax, #initialize, #label
Methods included from I18nExtra::Calendar
Methods included from OverflowExtra::Pagy
Methods included from FrontendHelpers::Calendar
Methods inherited from Pagy
#initialize, #label, root, #series
Methods included from SearchkickExtra::Pagy
Methods included from MeilisearchExtra::Pagy
Methods included from ElasticsearchRailsExtra::Pagy
Methods included from GearboxExtra
#setup_items_var, #setup_pages_var
Methods included from FrontendHelpers::Pagy
Constructor Details
This class inherits a constructor from Pagy::Calendar
Instance Method Details
#label_for(page, **opts) ⇒ Object
Generate a label for each page (it can pass along the I18n gem opts when it’s used with the i18n extra)
179 180 181 182 |
# File 'lib/pagy/calendar.rb', line 179 def label_for(page, **opts) opts[:format] ||= @vars[:day_format] localize(@initial + (snap(page.to_i) * DAY), **opts) end |
#setup_unit_vars ⇒ Object
Setup the calendar vars when the unit is :day
169 170 171 172 173 174 175 176 |
# File 'lib/pagy/calendar.rb', line 169 def setup_unit_vars min, max = super(:day_format) @initial = new_time(min.year, min.month, min.day) @final = new_time(max.year, max.month, max.day) + DAY @pages = @last = (@final - @initial).to_i / DAY @utc_from = (@initial + (snap * DAY)).utc @utc_to = @utc_from + DAY end |