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 buckets. Default is no limit.
[[["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-09-03 UTC."],[],[],null,["# Cloud Storage API - Class Google::Cloud::Storage::Bucket::List (v1.57.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.57.0 (latest)](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket-List)\n- [1.56.0](/ruby/docs/reference/google-cloud-storage/1.56.0/Google-Cloud-Storage-Bucket-List)\n- [1.55.0](/ruby/docs/reference/google-cloud-storage/1.55.0/Google-Cloud-Storage-Bucket-List)\n- [1.54.0](/ruby/docs/reference/google-cloud-storage/1.54.0/Google-Cloud-Storage-Bucket-List)\n- [1.53.0](/ruby/docs/reference/google-cloud-storage/1.53.0/Google-Cloud-Storage-Bucket-List)\n- [1.52.0](/ruby/docs/reference/google-cloud-storage/1.52.0/Google-Cloud-Storage-Bucket-List)\n- [1.51.0](/ruby/docs/reference/google-cloud-storage/1.51.0/Google-Cloud-Storage-Bucket-List)\n- [1.50.0](/ruby/docs/reference/google-cloud-storage/1.50.0/Google-Cloud-Storage-Bucket-List)\n- [1.49.0](/ruby/docs/reference/google-cloud-storage/1.49.0/Google-Cloud-Storage-Bucket-List)\n- [1.48.1](/ruby/docs/reference/google-cloud-storage/1.48.1/Google-Cloud-Storage-Bucket-List)\n- [1.47.0](/ruby/docs/reference/google-cloud-storage/1.47.0/Google-Cloud-Storage-Bucket-List)\n- [1.46.0](/ruby/docs/reference/google-cloud-storage/1.46.0/Google-Cloud-Storage-Bucket-List)\n- [1.45.0](/ruby/docs/reference/google-cloud-storage/1.45.0/Google-Cloud-Storage-Bucket-List)\n- [1.44.0](/ruby/docs/reference/google-cloud-storage/1.44.0/Google-Cloud-Storage-Bucket-List)\n- [1.43.0](/ruby/docs/reference/google-cloud-storage/1.43.0/Google-Cloud-Storage-Bucket-List)\n- [1.42.0](/ruby/docs/reference/google-cloud-storage/1.42.0/Google-Cloud-Storage-Bucket-List)\n- [1.41.0](/ruby/docs/reference/google-cloud-storage/1.41.0/Google-Cloud-Storage-Bucket-List)\n- [1.40.0](/ruby/docs/reference/google-cloud-storage/1.40.0/Google-Cloud-Storage-Bucket-List)\n- [1.39.0](/ruby/docs/reference/google-cloud-storage/1.39.0/Google-Cloud-Storage-Bucket-List)\n- [1.38.0](/ruby/docs/reference/google-cloud-storage/1.38.0/Google-Cloud-Storage-Bucket-List)\n- [1.37.0](/ruby/docs/reference/google-cloud-storage/1.37.0/Google-Cloud-Storage-Bucket-List)\n- [1.36.2](/ruby/docs/reference/google-cloud-storage/1.36.2/Google-Cloud-Storage-Bucket-List)\n- [1.35.0](/ruby/docs/reference/google-cloud-storage/1.35.0/Google-Cloud-Storage-Bucket-List) \nReference documentation and code samples for the Cloud Storage API class Google::Cloud::Storage::Bucket::List.\n\nBucket::List is a special case Array with additional values. \n\nInherits\n--------\n\n- Array\n\nMethods\n-------\n\n### #all\n\n def all(request_limit: nil, &block) { |bucket| ... } -\u003e Enumerator\n\nRetrieves remaining results by repeatedly invoking [#next](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket-List#Google__Cloud__Storage__Bucket__List_next_instance_ \"Google::Cloud::Storage::Bucket::List#next (method)\") until\n[#next?](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Bucket-List#Google__Cloud__Storage__Bucket__List_next__instance_ \"Google::Cloud::Storage::Bucket::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 buckets. Default is no limit. \n**Yields**\n\n- (bucket) --- The block for accessing each bucket. \n**Yield Parameter**\n\n- **bucket** ([Bucket](./Google-Cloud-Storage-Bucket)) --- The bucket object. \n**Returns**\n\n- (Enumerator)\n**Examples**\n\nIterating each bucket by passing a block: \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud::Storage.new\n\nbuckets = storage.buckets\nbuckets.all do |bucket|\n puts bucket.name\nend\n```\n\nUsing the enumerator by not passing a block: \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud::Storage.new\n\nbuckets = storage.buckets\nall_names = buckets.all.map do |bucket|\n bucket.name\nend\n```\n\nLimit the number of API calls made: \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud::Storage.new\n\nbuckets = storage.buckets\nbuckets.all(request_limit: 10) do |bucket|\n puts bucket.name\nend\n```\n\n### #next\n\n def next() -\u003e Bucket::List\n\nRetrieve the next page of buckets. \n**Returns**\n\n- ([Bucket::List](./Google-Cloud-Storage-Bucket-List))\n**Example** \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud::Storage.new\n\nbuckets = storage.buckets\nif buckets.next?\n next_buckets = buckets.next\nend\n```\n\n### #next?\n\n def next?() -\u003e Boolean\n\nWhether there is a next page of buckets. \n**Returns**\n\n- (Boolean)\n**Example** \n\n```ruby\nrequire \"google/cloud/storage\"\n\nstorage = Google::Cloud::Storage.new\n\nbuckets = storage.buckets\nif buckets.next?\n next_buckets = buckets.next\nend\n```\n\n### #token\n\n def token()\n\nIf not empty, indicates that there are more buckets\nthat match the request and this value should be passed to\nthe next [Project#buckets](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Project#Google__Cloud__Storage__Project_buckets_instance_ \"Google::Cloud::Storage::Project#buckets (method)\") to continue.\n\n### #token=\n\n def token=(value)\n\nIf not empty, indicates that there are more buckets\nthat match the request and this value should be passed to\nthe next [Project#buckets](/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Project#Google__Cloud__Storage__Project_buckets_instance_ \"Google::Cloud::Storage::Project#buckets (method)\") to continue."]]