Sha256: 7f4c530174b82ffed9fa00bebe846d2e96ce8b0079f3e369853eb491144d8a08

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


require "delegate"

module Gcloud
  module Storage
    class File
      ##
      # File::List is a special case Array with additional values.
      class List < DelegateClass(::Array)
        ##
        # If not empty, indicates that there are more buckets
        # that match the request and this value should be passed to
        # the next Gcloud::Storage::Bucket#files to continue.
        attr_accessor :token

        # The list of prefixes of objects matching-but-not-listed up
        # to and including the requested delimiter.
        attr_accessor :prefixes

        ##
        # Create a new File::List with an array of values.
        def initialize arr = [], token = nil, prefixes = []
          super arr
          @token = token
          @prefixes = prefixes
        end

        ##
        # @private New File::List from a response object.
        def self.from_response resp, conn
          buckets = Array(resp.data["items"]).map do |gapi_object|
            File.from_gapi gapi_object, conn
          end
          token = resp.data["nextPageToken"]
          prefixes = Array resp.data["prefixes"]
          new buckets, token, prefixes
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gcloud-0.10.0 lib/gcloud/storage/file/list.rb
gcloud-0.9.0 lib/gcloud/storage/file/list.rb
gcloud-0.8.2 lib/gcloud/storage/file/list.rb
gcloud-0.8.0 lib/gcloud/storage/file/list.rb
gcloud-0.7.2 lib/gcloud/storage/file/list.rb
gcloud-0.7.1 lib/gcloud/storage/file/list.rb
gcloud-0.7.0 lib/gcloud/storage/file/list.rb