1.5.0 (latest) 1.4.1 1.3.0 1.2.0 1.1.0 1.0.1 0.26.0 0.25.0 0.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.


<br />

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.

```ruby
paged_enumerable.each { |resource| puts resource }
```

per-page iteration.

```ruby
paged_enumerable.each_page { |page| puts page }
```

Enumerable over pages.

```ruby
paged_enumerable.each_page do |page|
  page.each { |resource| puts resource }
end
```

more exact operations over pages.

```ruby
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](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-PagedEnumerable-Page)) --- Gives the pages in the stream.
**Raises**

- --- if it's not started yet.

### #next_page

    def next_page() -> Page

**Alias Of** : [#next_page!](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-PagedEnumerable#Gapic__PagedEnumerable_next_page!_instance_) Update the response in the current page.
**Returns**

- ([Page](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-PagedEnumerable-Page)) --- the new page object.

### #next_page!

    def next_page!() -> Page

**Aliases**

- [#next_page](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-PagedEnumerable#Gapic__PagedEnumerable_next_page_instance_)
Update the response in the current page.
**Returns**

- ([Page](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-PagedEnumerable-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)