Class: Pinnacle::Internal::ItemIterator
- Inherits:
-
Object
- Object
- Pinnacle::Internal::ItemIterator
- Includes:
- Enumerable
- Defined in:
- lib/pinnacle/internal/iterators/item_iterator.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#each(&block) ⇒ NilClass
Iterates over each item returned by the API.
-
#http_response ⇒ Net::HTTPResponse?
The raw HTTP response from the most recent page response.
-
#next? ⇒ Boolean
Whether another item will be available from the API.
-
#next_element ⇒ Object
Retrieves the next item from the API.
Instance Method Details
#each(&block) ⇒ NilClass
Iterates over each item returned by the API.
18 19 20 21 22 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 18 def each(&block) while (item = next_element) block.call(item) end end |
#http_response ⇒ Net::HTTPResponse?
The raw HTTP response from the most recent page response.
10 11 12 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 10 def http_response @page_iterator&.http_response end |
#next? ⇒ Boolean
Whether another item will be available from the API.
27 28 29 30 31 32 33 34 35 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 27 def next? load_next_page if @page.nil? return false if @page.nil? return true if any_items_in_cached_page? load_next_page any_items_in_cached_page? end |
#next_element ⇒ Object
Retrieves the next item from the API.
38 39 40 41 42 43 44 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 38 def next_element item = next_item_from_cached_page return item if item load_next_page next_item_from_cached_page end |