Class: WrAPI::RequestPagination::DefaultPager
- Inherits:
-
Object
- Object
- WrAPI::RequestPagination::DefaultPager
- Defined in:
- lib/wrapi/pagination.rb
Overview
DefaultPager handles pagination by assuming all data is retrieved in a single go.
Class Method Summary collapse
-
.data(body) ⇒ Object
Processes the data from the response body.
Instance Method Summary collapse
-
#initialize(_page_size = nil) ⇒ DefaultPager
constructor
Initializes the pager with an optional page size.
-
#more_pages? ⇒ Boolean
Checks if there are more pages.
-
#next_page!(_data = nil) ⇒ Boolean
Advances to the next page.
-
#page_options ⇒ Hash
Returns options for the current page to add to get request.
Constructor Details
#initialize(_page_size = nil) ⇒ DefaultPager
Initializes the pager with an optional page size.
14 15 16 |
# File 'lib/wrapi/pagination.rb', line 14 def initialize(_page_size = nil) @page = 0 end |
Class Method Details
.data(body) ⇒ Object
Processes the data from the response body.
45 46 47 |
# File 'lib/wrapi/pagination.rb', line 45 def self.data(body) body end |
Instance Method Details
#more_pages? ⇒ Boolean
Checks if there are more pages.
30 31 32 |
# File 'lib/wrapi/pagination.rb', line 30 def more_pages? @page < 1 end |
#next_page!(_data = nil) ⇒ Boolean
Advances to the next page.
22 23 24 25 |
# File 'lib/wrapi/pagination.rb', line 22 def next_page!(_data = nil) @page += 1 more_pages? end |
#page_options ⇒ Hash
Returns options for the current page to add to get request.
37 38 39 |
# File 'lib/wrapi/pagination.rb', line 37 def {} end |