Class: Drillbit::Parameters::Page
- Inherits:
-
Object
- Object
- Drillbit::Parameters::Page
- Defined in:
- lib/drillbit/parameters/page.rb
Constant Summary collapse
- PAGING_PARAMETERS =
%w{number size limit offset cursor}.freeze
- DEFAULT_STARTING_PAGE =
1
- DEFAULT_PAGE_SIZE =
25
Instance Attribute Summary collapse
-
#raw_parameters ⇒ Object
Returns the value of attribute raw_parameters.
Instance Method Summary collapse
-
#initialize(raw_parameters) ⇒ Page
constructor
A new instance of Page.
- #page_number ⇒ Object
- #per_page ⇒ Object
- #present? ⇒ Boolean
Constructor Details
#initialize(raw_parameters) ⇒ Page
Returns a new instance of Page.
12 13 14 |
# File 'lib/drillbit/parameters/page.rb', line 12 def initialize(raw_parameters) self.raw_parameters = raw_parameters || {} end |
Instance Attribute Details
#raw_parameters ⇒ Object
Returns the value of attribute raw_parameters.
10 11 12 |
# File 'lib/drillbit/parameters/page.rb', line 10 def raw_parameters @raw_parameters end |
Instance Method Details
#page_number ⇒ Object
20 21 22 |
# File 'lib/drillbit/parameters/page.rb', line 20 def page_number raw_parameters['number'] || DEFAULT_STARTING_PAGE end |
#per_page ⇒ Object
24 25 26 |
# File 'lib/drillbit/parameters/page.rb', line 24 def per_page raw_parameters['size'] || DEFAULT_PAGE_SIZE end |
#present? ⇒ Boolean
16 17 18 |
# File 'lib/drillbit/parameters/page.rb', line 16 def present? (raw_parameters.keys & PAGING_PARAMETERS).any? end |