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

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

Constants inherited from Pagy::Calendar

UNITS

Constants inherited from Pagy

ElasticsearchRails, LABEL_PLACEHOLDER, Meilisearch, PAGE_PLACEHOLDER, 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::Calendar

#localize

Methods included from OverflowExtra::Pagy

#initialize, #overflow?

Methods included from FrontendHelpers::Calendar

#label_sequels

Methods inherited from Pagy

#initialize, #label, root, #series

Methods included from SearchkickExtra::Pagy

#new_from_searchkick

Methods included from MeilisearchExtra::Pagy

#new_from_meilisearch

Methods included from ElasticsearchRailsExtra::Pagy

#new_from_elasticsearch_rails

Methods included from GearboxExtra

#setup_items_var, #setup_offset_var, #setup_pages_var

Methods included from FrontendHelpers::Pagy

#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



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

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