gapic-common - Class Gapic::PagedEnumerable (v0.24.0)

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.

Yields
  • (Object) — Gives the resource objects in the stream.
Raises
  • (RuntimeError) — if it's not started yet.

#each_page

def each_page()

Iterate over the pages.

Yields
  • (Page) — Gives the pages in the stream.
Raises
  • — if it's not started yet.

#next_page

def next_page() -> Page
Alias Of: #next_page!

Update the response in the current page.

Returns
  • (Page) — the new page object.

#next_page!

def next_page!() -> Page
Aliases

Update the response in the current page.

Returns
  • (Page) — the new page object.

#next_page?

def next_page?() -> Boolean

True if it has the next page.

Returns
  • (Boolean)

#next_page_token

def next_page_token() -> String

The page token to be used for the next RPC call.

Returns
  • (String)

#page

def page()

Returns the value of attribute page.

#response

def response() -> Object

The current response object, for the current page.

Returns
  • (Object)