Class: Gcloud::Storage::File::List

Inherits:
Array
  • Object
show all
Defined in:
lib/gcloud/storage/file/list.rb

Overview

File::List is a special case Array with additional values.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arr = [], token = nil, prefixes = []) ⇒ List

Create a new File::List with an array of values.



33
34
35
36
37
# File 'lib/gcloud/storage/file/list.rb', line 33

def initialize arr = [], token = nil, prefixes = []
  super arr
  @token = token
  @prefixes = prefixes
end

Instance Attribute Details

#prefixesObject

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



29
30
31
# File 'lib/gcloud/storage/file/list.rb', line 29

def prefixes
  @prefixes
end

#tokenObject

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.



25
26
27
# File 'lib/gcloud/storage/file/list.rb', line 25

def token
  @token
end

Class Method Details

.from_resp(resp, conn) ⇒ Object

New File::List from a response object.



41
42
43
44
45
46
47
48
# File 'lib/gcloud/storage/file/list.rb', line 41

def self.from_resp resp, conn #:nodoc:
  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