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.
-
#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.
12 13 14 15 16 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 12 def each(&block) while (item = next_element) block.call(item) end end |
#next? ⇒ Boolean
Whether another item will be available from the API.
21 22 23 24 25 26 27 28 29 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 21 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.
32 33 34 35 36 37 38 |
# File 'lib/pinnacle/internal/iterators/item_iterator.rb', line 32 def next_element item = next_item_from_cached_page return item if item load_next_page next_item_from_cached_page end |