Reference documentation and code samples for the gapic-common class Gapic::PagedEnumerable.
A class to provide the Enumerable interface to the response of a paginated method. PagedEnumerable assumes response message holds a list of resources and the token to the next page.
PagedEnumerable provides the enumerations over the resource data, and also provides the enumerations over the pages themselves.
Inherits
- Object
Includes
- Enumerable
Examples
normal iteration over resources.
paged_enumerable.each { |resource| puts resource }
per-page iteration.
paged_enumerable.each_page { |page| puts page }
Enumerable over pages.
paged_enumerable.each_page do |page| page.each { |resource| puts resource } end
more exact operations over pages.
while some_condition() page = paged_enumerable.page do_something(page) break if paged_enumerable.next_page? paged_enumerable.next_page end
Methods
#each
def each(&block)
Iterate over the resources.
- (Object) — Gives the resource objects in the stream.
- (RuntimeError) — if it's not started yet.
#each_page
def each_page()
Iterate over the pages.
- (Page) — Gives the pages in the stream.
- — if it's not started yet.
#next_page
def next_page() -> Page
Update the response in the current page.
- (Page) — the new page object.
#next_page!
def next_page!() -> Page
Update the response in the current page.
- (Page) — the new page object.
#next_page?
def next_page?() -> Boolean
True if it has the next page.
- (Boolean)
#next_page_token
def next_page_token() -> String
The page token to be used for the next RPC call.
- (String)
#page
def page()
Returns the value of attribute page.
#response
def response() -> Object
The current response object, for the current page.
- (Object)