Retrieves remaining results by repeatedly invoking #next until
#next? returns false. Calls the given block once for each
result, which is passed as the argument to the block.
An Enumerator is returned if no block is given.
This method will make repeated API calls until all remaining results
are retrieved. (Unlike #each, for example, which merely iterates
over the results returned by a single API call.) Use with caution.
Parameter
request_limit (Integer) (defaults to: nil) — The upper limit of API requests to
make to load all instances. Default is no limit.
Yields
(instance) — The block for accessing each instance.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Cloud Spanner API - Class Google::Cloud::Spanner::Instance::List (v2.27.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.27.0 (latest)](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-List)\n- [2.26.0](/ruby/docs/reference/google-cloud-spanner/2.26.0/Google-Cloud-Spanner-Instance-List)\n- [2.25.0](/ruby/docs/reference/google-cloud-spanner/2.25.0/Google-Cloud-Spanner-Instance-List)\n- [2.24.0](/ruby/docs/reference/google-cloud-spanner/2.24.0/Google-Cloud-Spanner-Instance-List)\n- [2.23.0](/ruby/docs/reference/google-cloud-spanner/2.23.0/Google-Cloud-Spanner-Instance-List)\n- [2.22.0](/ruby/docs/reference/google-cloud-spanner/2.22.0/Google-Cloud-Spanner-Instance-List)\n- [2.21.0](/ruby/docs/reference/google-cloud-spanner/2.21.0/Google-Cloud-Spanner-Instance-List)\n- [2.20.0](/ruby/docs/reference/google-cloud-spanner/2.20.0/Google-Cloud-Spanner-Instance-List)\n- [2.19.1](/ruby/docs/reference/google-cloud-spanner/2.19.1/Google-Cloud-Spanner-Instance-List)\n- [2.18.1](/ruby/docs/reference/google-cloud-spanner/2.18.1/Google-Cloud-Spanner-Instance-List)\n- [2.17.0](/ruby/docs/reference/google-cloud-spanner/2.17.0/Google-Cloud-Spanner-Instance-List)\n- [2.16.1](/ruby/docs/reference/google-cloud-spanner/2.16.1/Google-Cloud-Spanner-Instance-List)\n- [2.15.0](/ruby/docs/reference/google-cloud-spanner/2.15.0/Google-Cloud-Spanner-Instance-List)\n- [2.14.0](/ruby/docs/reference/google-cloud-spanner/2.14.0/Google-Cloud-Spanner-Instance-List)\n- [2.13.0](/ruby/docs/reference/google-cloud-spanner/2.13.0/Google-Cloud-Spanner-Instance-List)\n- [2.12.1](/ruby/docs/reference/google-cloud-spanner/2.12.1/Google-Cloud-Spanner-Instance-List)\n- [2.11.0](/ruby/docs/reference/google-cloud-spanner/2.11.0/Google-Cloud-Spanner-Instance-List) \nReference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Instance::List.\n\nInstance::List is a special case Array with additional\nvalues. \n\nInherits\n--------\n\n- Array\n\nMethods\n-------\n\n### #all\n\n def all(request_limit: nil, &block) { |instance| ... } -\u003e Enumerator\n\nRetrieves remaining results by repeatedly invoking [#next](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-List#Google__Cloud__Spanner__Instance__List_next_instance_ \"Google::Cloud::Spanner::Instance::List#next (method)\") until\n[#next?](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-List#Google__Cloud__Spanner__Instance__List_next__instance_ \"Google::Cloud::Spanner::Instance::List#next? (method)\") returns `false`. Calls the given block once for each\nresult, which is passed as the argument to the block.\n\n\nAn Enumerator is returned if no block is given.\n\n\u003cbr /\u003e\n\nThis method will make repeated API calls until all remaining results\nare retrieved. (Unlike `#each`, for example, which merely iterates\nover the results returned by a single API call.) Use with caution. \n**Parameter**\n\n- **request_limit** (Integer) *(defaults to: nil)* --- The upper limit of API requests to make to load all instances. Default is no limit. \n**Yields**\n\n- (instance) --- The block for accessing each instance. \n**Yield Parameter**\n\n- **instance** (Instance) --- The instance object. \n**Returns**\n\n- (Enumerator)\n**Examples**\n\nIterating each instance by passing a block: \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\nspanner.instances.all do |instance|\n puts instance.instance_id\nend\n```\n\nUsing the enumerator by not passing a block: \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\nall_instance_ids = spanner.instances.all.map do |instance|\n instance.instance_id\nend\n```\n\nLimit the number of API calls made: \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\nspanner.instances.all(request_limit: 10) do |instance|\n puts instance.instance_id\nend\n```\n\n### #next\n\n def next() -\u003e Instance::List\n\nRetrieve the next page of instances. \n**Returns**\n\n- ([Instance::List](./Google-Cloud-Spanner-Instance-List)) --- The list of instances.\n**Example** \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\ninstances = spanner.instances\nif instances.next?\n next_instances = instances.next\nend\n```\n\n### #next?\n\n def next?() -\u003e Boolean\n\nWhether there is a next page of instances. \n**Returns**\n\n- (Boolean)\n**Example** \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\ninstances = spanner.instances\nif instances.next?\n next_instances = instances.next\nend\n```\n\n### #token\n\n def token()\n\nIf not empty, indicates that there are more records that match\nthe request and this value should be passed to continue.\n\n### #token=\n\n def token=(value)\n\nIf not empty, indicates that there are more records that match\nthe request and this value should be passed to continue."]]