Class: Poms::Api::PaginationClient::Page
- Inherits:
-
Object
- Object
- Poms::Api::PaginationClient::Page
- Defined in:
- lib/poms/api/pagination_client.rb
Overview
Keep track of number of items and how many have been retrieved
Instance Method Summary collapse
- #execute ⇒ Object
- #final? ⇒ Boolean
-
#initialize(uri, offset = 0) ⇒ Page
constructor
A new instance of Page.
- #items ⇒ Object
- #next_page ⇒ Object
Constructor Details
#initialize(uri, offset = 0) ⇒ Page
Returns a new instance of Page.
32 33 34 35 |
# File 'lib/poms/api/pagination_client.rb', line 32 def initialize(uri, offset = 0) uri.query_values = { offset: } @uri = uri end |
Instance Method Details
#execute ⇒ Object
49 50 51 |
# File 'lib/poms/api/pagination_client.rb', line 49 def execute @response = yield uri end |
#final? ⇒ Boolean
41 42 43 |
# File 'lib/poms/api/pagination_client.rb', line 41 def final? next_index >= response['total'] end |
#items ⇒ Object
45 46 47 |
# File 'lib/poms/api/pagination_client.rb', line 45 def items response['items'] end |
#next_page ⇒ Object
37 38 39 |
# File 'lib/poms/api/pagination_client.rb', line 37 def next_page self.class.new(uri, next_index) end |