Class: Pagy::Calendar::Year
- Inherits:
-
Pagy::Calendar
- Object
- Pagy
- Pagy::Calendar
- Pagy::Calendar::Year
- Defined in:
- lib/pagy/calendar.rb
Overview
Calendar year 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 :year.
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)
96 97 98 99 |
# File 'lib/pagy/calendar.rb', line 96 def label_for(page, **opts) opts[:format] ||= @vars[:year_format] localize(new_time(@initial.year + snap(page.to_i)), **opts) end |
#setup_unit_vars ⇒ Object
Setup the calendar vars when the unit is :year
86 87 88 89 90 91 92 93 |
# File 'lib/pagy/calendar.rb', line 86 def setup_unit_vars min, max = super(:year_format) @initial = new_time(min.year) @final = new_time(max.year + 1) @pages = @last = @final.year - @initial.year @utc_from = new_time(@initial.year + snap).utc @utc_to = new_time(@initial.year + snap + 1).utc end |