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.
[[["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::PagedEnumerable (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/gapic-common/latest/Gapic-PagedEnumerable)\n- [1.0.1](/ruby/docs/reference/gapic-common/1.0.1/Gapic-PagedEnumerable)\n- [0.26.0](/ruby/docs/reference/gapic-common/0.26.0/Gapic-PagedEnumerable)\n- [0.25.0](/ruby/docs/reference/gapic-common/0.25.0/Gapic-PagedEnumerable)\n- [0.24.0](/ruby/docs/reference/gapic-common/0.24.0/Gapic-PagedEnumerable) \nReference documentation and code samples for the gapic-common class Gapic::PagedEnumerable.\n\nA class to provide the Enumerable interface to the response of a paginated method. PagedEnumerable assumes\nresponse 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)\n\nIterate over the resources. \n**Yields**\n\n- (Object) --- Gives the resource objects in the stream. \n**Raises**\n\n- (RuntimeError) --- if it's not started yet.\n\n### #each_page\n\n def each_page()\n\nIterate over the pages. \n**Yields**\n\n- ([Page](./Gapic-PagedEnumerable-Page)) --- Gives the pages in the stream. \n**Raises**\n\n- --- if it's not started yet.\n\n### #next_page\n\n def next_page() -\u003e Page\n\n**Alias Of** : [#next_page!](./Gapic-PagedEnumerable#Gapic__PagedEnumerable_next_page!_instance_) \nUpdate the response in the current page. \n**Returns**\n\n- ([Page](./Gapic-PagedEnumerable-Page)) --- the new page object.\n\n### #next_page!\n\n def next_page!() -\u003e Page\n\n**Aliases**\n\n- [#next_page](./Gapic-PagedEnumerable#Gapic__PagedEnumerable_next_page_instance_) \nUpdate the response in the current page. \n**Returns**\n\n- ([Page](./Gapic-PagedEnumerable-Page)) --- the new page object.\n\n### #next_page?\n\n def next_page?() -\u003e Boolean\n\nTrue if it has the next page. \n**Returns**\n\n- (Boolean)\n\n### #next_page_token\n\n def next_page_token() -\u003e String\n\nThe page token to be used for the next RPC call. \n**Returns**\n\n- (String)\n\n### #page\n\n def page()\n\nReturns the value of attribute page.\n\n### #response\n\n def response() -\u003e Object\n\nThe current response object, for the current page. \n**Returns**\n\n- (Object)"]]