Class: Pagy::Calendar::Quarter

Inherits:
Pagy::Calendar show all
Defined in:
lib/pagy/calendar/quarter.rb

Overview

Calendar quarter subclass

Constant Summary collapse

DEFAULT =

rubocop:disable Style/MutableConstant

{ size:   4,      # rubocop:disable Style/MutableConstant
order:  :asc,
format: 'Q%q' }

Constants inherited from Pagy::Calendar

UNITS

Constants inherited from Pagy

ElasticsearchRails, LABEL_TOKEN, Meilisearch, PAGE_TOKEN, Searchkick, VERSION

Instance Attribute Summary

Attributes inherited from Pagy::Calendar

#from, #order, #to

Attributes inherited from Pagy

#count, #from, #in, #items, #last, #next, #offset, #page, #pages, #params, #prev, #request_path, #to, #vars

Instance Method Summary collapse

Methods inherited from Pagy::Calendar

create, #initialize, #label

Methods included from I18nExtra::CalendarOverride

#localize

Methods included from OverflowExtra::PagyOverride

#initialize, #overflow?

Methods included from FrontendHelpers::CalendarOverride

#label_sequels

Methods inherited from Pagy

#initialize, #label, root, #series

Methods included from SearchkickExtra::PagyExtension

#new_from_searchkick

Methods included from MeilisearchExtra::PagyExtension

#new_from_meilisearch

Methods included from ElasticsearchRailsExtra::PagyAddOn

#new_from_elasticsearch_rails

Methods included from GearboxExtra

#setup_items_var, #setup_offset_var, #setup_pages_var

Methods included from FrontendHelpers::PagyAddOn

#label_sequels, #sequels

Constructor Details

This class inherits a constructor from Pagy::Calendar

Instance Method Details

#label_for(page, opts = {}) ⇒ Object

The label for any page, with the substitution of the ‘%q’ token



13
14
15
16
17
# File 'lib/pagy/calendar/quarter.rb', line 13

def label_for(page, opts = {})
  starting_time = starting_time_for(page.to_i)  # page could be a string
  opts[:format] = (opts[:format] || @vars[:format]).gsub('%q') { (starting_time.month / 3.0).ceil }
  localize(starting_time, opts)
end