Reference documentation and code samples for the gapic-common class Gapic::Rest::PagedEnumerable.
A class to provide the Enumerable interface to the response of a REST 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# gapic-common - Class Gapic::Rest::PagedEnumerable (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/gapic-common/latest/Gapic-Rest-PagedEnumerable)\n- [1.0.1](/ruby/docs/reference/gapic-common/1.0.1/Gapic-Rest-PagedEnumerable)\n- [0.26.0](/ruby/docs/reference/gapic-common/0.26.0/Gapic-Rest-PagedEnumerable)\n- [0.25.0](/ruby/docs/reference/gapic-common/0.25.0/Gapic-Rest-PagedEnumerable)\n- [0.24.0](/ruby/docs/reference/gapic-common/0.24.0/Gapic-Rest-PagedEnumerable) \nReference documentation and code samples for the gapic-common class Gapic::Rest::PagedEnumerable.\n\nA class to provide the Enumerable interface to the response of a REST paginated method.\nPagedEnumerable assumes response message holds a list of resources and the token to the next page.\n\n\n\u003cbr /\u003e\n\nPagedEnumerable provides the enumerations over the resource data, and also provides the enumerations over the\npages themselves. \n\nInherits\n--------\n\n- Object \n\nIncludes\n--------\n\n- Enumerable\n\nExamples\n--------\n\nnormal iteration over resources. \n\n```ruby\npaged_enumerable.each { |resource| puts resource }\n```\n\nper-page iteration. \n\n```ruby\npaged_enumerable.each_page { |page| puts page }\n```\n\nEnumerable over pages. \n\n```ruby\npaged_enumerable.each_page do |page|\n page.each { |resource| puts resource }\nend\n```\n\nmore exact operations over pages. \n\n```ruby\nwhile some_condition()\n page = paged_enumerable.page\n do_something(page)\n break if paged_enumerable.next_page?\n paged_enumerable.next_page\nend\n```\n\nMethods\n-------\n\n### #each\n\n def each(&block) -\u003e Enumerator\n\nIterate over the individual resources, automatically requesting new pages as needed. \n**Yields**\n\n- (Object) --- Gives the resource objects in the stream. \n**Returns**\n\n- (Enumerator) --- if no block is provided\n\n### #each_page\n\n def each_page() -\u003e Enumerator\n\nIterate over the pages. \n**Yields**\n\n- ([Page](./Gapic-Rest-PagedEnumerable-Page)) --- Gives the pages in the stream. \n**Returns**\n\n- (Enumerator) --- if no block is provided\n\n### #next_page\n\n def next_page() -\u003e Page, nil\n\n**Alias Of** : [#next_page!](./Gapic-Rest-PagedEnumerable#Gapic__Rest__PagedEnumerable_next_page!_instance_) \nLoad the next page and set it as the current page.\nIf there is no next page, sets nil as a current page. \n**Returns**\n\n- ([Page](./Gapic-Rest-PagedEnumerable-Page), nil) --- the new page object.\n\n### #next_page!\n\n def next_page!() -\u003e Page, nil\n\n**Aliases**\n\n- [#next_page](./Gapic-Rest-PagedEnumerable#Gapic__Rest__PagedEnumerable_next_page_instance_) \nLoad the next page and set it as the current page.\nIf there is no next page, sets nil as a current page. \n**Returns**\n\n- ([Page](./Gapic-Rest-PagedEnumerable-Page), nil) --- the new page object.\n\n### #next_page?\n\n def next_page?() -\u003e Boolean\n\nTrue if there is at least one more page of results. \n**Returns**\n\n- (Boolean)\n\n### #next_page_token\n\n def next_page_token() -\u003e String, nil\n\nThe page token to be used for the next RPC call, or the empty string if there is no next page.\nnil if the iteration is complete. \n**Returns**\n\n- (String, nil)\n\n### #page\n\n def page() -\u003e Page\n\n**Returns**\n\n- ([Page](./Gapic-Rest-PagedEnumerable-Page)) --- The current page object.\n\n### #response\n\n def response() -\u003e Object, nil\n\nThe current response object, for the current page.\nnil if the iteration is complete. \n**Returns**\n\n- (Object, nil)"]]