Class: Buckets::Bucket
Overview
Bucket
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#add_object(name, data, content_type = 'binary/octet-stream', *args) ⇒ Object
add an object to this bucket pass in a name, a File or IO object, it’s content type and a hash containing additional headers (keys and values).
-
#delete(options = {}) ⇒ Object
Delete this bucket if it’s empty.
-
#initialize(*args) ⇒ Bucket
constructor
A new instance of Bucket.
Methods inherited from Utils
Constructor Details
#initialize(*args) ⇒ Bucket
Returns a new instance of Bucket.
97 98 99 100 101 102 |
# File 'lib/buckets.rb', line 97 def initialize(*args) = {} .merge!(args.pop) if args.last.is_a? Hash @name = [:name] @created_at = [:created_at] end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
95 96 97 |
# File 'lib/buckets.rb', line 95 def created_at @created_at end |
#name ⇒ Object
Returns the value of attribute name.
95 96 97 |
# File 'lib/buckets.rb', line 95 def name @name end |
Instance Method Details
#add_object(name, data, content_type = 'binary/octet-stream', *args) ⇒ Object
add an object to this bucket pass in a name, a File or IO object, it’s content type and a hash containing additional headers (keys and values)
117 118 119 120 121 122 123 124 125 |
# File 'lib/buckets.rb', line 117 def add_object(name, data, content_type='binary/octet-stream', *args) data.rewind additional_headers = { 'Content-MD5' => Base64.encode64(Digest::MD5.digest(data.read)).strip, 'Content-Type' => content_type } additional_headers.merge!(args.pop) if args.last.is_a? Hash connection.put("/#{URI.escape(name)}", @name, data, additional_headers) end |
#delete(options = {}) ⇒ Object
Delete this bucket if it’s empty
105 106 107 |
# File 'lib/buckets.rb', line 105 def delete(={}) connection.delete("/", @name) end |