Class: Pagy::Calendar::Unit
- Defined in:
- lib/pagy/classes/calendar/unit.rb
Overview
Base class for time units subclasses (Year, Quarter, Month, Week, Day)
To define a “bimester” unit you should:
-
Define a ‘Pagy::Calendar::Bimester` class
-
Add the ‘:bimester` unit symbol in the `Pagy::Calendar::UNITS`
-
Ensure the desc durtion order of the UNITS (i.e. insert it between ‘:quarter` and `:month`)
Constant Summary collapse
- DEFAULT =
{ page: 1 }.freeze
Constants inherited from Pagy
A_TAG, DEFAULT_DATA_KEYS, DEFAULT_HEADERS_MAP, LABEL_TOKEN, LIMIT_TOKEN, Method, PAGE_TOKEN, ROOT, SERIES_SLOTS, VERSION
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#last ⇒ Object
(also: #pages)
readonly
Returns the value of attribute last.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes inherited from Pagy
#in, #limit, #next, #options, #page
Instance Method Summary collapse
-
#initialize ⇒ Unit
constructor
A new instance of Unit.
Methods included from Rangeable
Methods inherited from Pagy
#data_hash, #headers_hash, #info_tag, #input_nav_js, #limit_tag_js, #next_tag, options, #page_url, #previous_tag, #series_nav, #series_nav_js, #urls_hash
Methods included from Pagy::Configurable
#dev_tools, #sync_javascript, #translate_with_the_slower_i18n_gem!
Constructor Details
#initialize ⇒ Unit
Returns a new instance of Unit.
20 21 22 23 24 25 26 27 |
# File 'lib/pagy/classes/calendar/unit.rb', line 20 def initialize(**) (**) assign_and_check(page: 1) assign_unit_variables return unless in_range? { @page <= @last } assign_previous_and_next end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
29 30 31 |
# File 'lib/pagy/classes/calendar/unit.rb', line 29 def from @from end |
#last ⇒ Object (readonly) Also known as: pages
Returns the value of attribute last.
29 30 31 |
# File 'lib/pagy/classes/calendar/unit.rb', line 29 def last @last end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
29 30 31 |
# File 'lib/pagy/classes/calendar/unit.rb', line 29 def order @order end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
29 30 31 |
# File 'lib/pagy/classes/calendar/unit.rb', line 29 def previous @previous end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
29 30 31 |
# File 'lib/pagy/classes/calendar/unit.rb', line 29 def to @to end |