Class: Buckets::BucketMetaObject
Overview
BucketMetaObject Contains information about an object
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
-
#e_tag ⇒ Object
Returns the value of attribute e_tag.
-
#key ⇒ Object
Returns the value of attribute key.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#owner_display_name ⇒ Object
Returns the value of attribute owner_display_name.
-
#owner_id ⇒ Object
Returns the value of attribute owner_id.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#size ⇒ Object
Returns the value of attribute size.
-
#storage_class ⇒ Object
Returns the value of attribute storage_class.
Instance Method Summary collapse
- #copy_to(bucket_name, path = nil) ⇒ Object
-
#delete ⇒ Object
Deletes the object from the bucket.
-
#initialize(*args) ⇒ BucketMetaObject
constructor
A new instance of BucketMetaObject.
-
#object ⇒ Object
When called, returns the previously set data of the object.
-
#object! ⇒ Object
Forces retrieval of the object data from Google Storage.
Methods inherited from Utils
Constructor Details
#initialize(*args) ⇒ BucketMetaObject
Returns a new instance of BucketMetaObject.
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/buckets.rb', line 136 def initialize(*args) @properties = args.first @bucket_name = @properties[:bucket_name] @key = @properties[:key] @last_modified = @properties[:last_modified] @e_tag = @properties[:e_tag] @size = @properties[:size] @storage_class = @properties[:storage_class] @owner_id = @properties[:owner_id] @owner_display_name = @properties[:owner_display_name] end |
Instance Attribute Details
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
131 132 133 |
# File 'lib/buckets.rb', line 131 def bucket_name @bucket_name end |
#e_tag ⇒ Object
Returns the value of attribute e_tag.
131 132 133 |
# File 'lib/buckets.rb', line 131 def e_tag @e_tag end |
#key ⇒ Object
Returns the value of attribute key.
131 132 133 |
# File 'lib/buckets.rb', line 131 def key @key end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
131 132 133 |
# File 'lib/buckets.rb', line 131 def last_modified @last_modified end |
#owner_display_name ⇒ Object
Returns the value of attribute owner_display_name.
131 132 133 |
# File 'lib/buckets.rb', line 131 def owner_display_name @owner_display_name end |
#owner_id ⇒ Object
Returns the value of attribute owner_id.
131 132 133 |
# File 'lib/buckets.rb', line 131 def owner_id @owner_id end |
#properties ⇒ Object
Returns the value of attribute properties.
131 132 133 |
# File 'lib/buckets.rb', line 131 def properties @properties end |
#size ⇒ Object
Returns the value of attribute size.
131 132 133 |
# File 'lib/buckets.rb', line 131 def size @size end |
#storage_class ⇒ Object
Returns the value of attribute storage_class.
131 132 133 |
# File 'lib/buckets.rb', line 131 def storage_class @storage_class end |
Instance Method Details
#copy_to(bucket_name, path = nil) ⇒ Object
165 166 167 168 |
# File 'lib/buckets.rb', line 165 def copy_to(bucket_name, path=nil) path = "/#{path.nil? ? URI.escape(@key) : URI.escape(path)}" connection.put(path, bucket_name, nil, {'x-goog-copy-source' => "#{@bucket_name}/#{URI.escape(@key)}"}) end |
#delete ⇒ Object
Deletes the object from the bucket.
161 162 163 |
# File 'lib/buckets.rb', line 161 def delete connection.delete("/#{URI.escape(@key)}", @bucket_name) end |
#object ⇒ Object
When called, returns the previously set data of the object. If the object data hasn’t been set, it will go fetch it from Google Storage and set it as an instance variable to be returned next time.
151 152 153 |
# File 'lib/buckets.rb', line 151 def object @object ||= object! end |
#object! ⇒ Object
Forces retrieval of the object data from Google Storage.
156 157 158 |
# File 'lib/buckets.rb', line 156 def object! connection.get("/#{URI.escape(@key)}", @bucket_name) end |