Class: Drillbit::Parameters::Page

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_parametersObject

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_numberObject



20
21
22
# File 'lib/drillbit/parameters/page.rb', line 20

def page_number
  raw_parameters['number'] || DEFAULT_STARTING_PAGE
end

#per_pageObject



24
25
26
# File 'lib/drillbit/parameters/page.rb', line 24

def per_page
  raw_parameters['size'] || DEFAULT_PAGE_SIZE
end

#present?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/drillbit/parameters/page.rb', line 16

def present?
  (raw_parameters.keys & PAGING_PARAMETERS).any?
end