Class: Hubic::Container
- Inherits:
-
Object
- Object
- Hubic::Container
- Defined in:
- lib/hubic/openstack.rb
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #destroy! ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(hubic, name) ⇒ Container
constructor
A new instance of Container.
- #object(path) ⇒ Object
- #objects ⇒ Object
Constructor Details
#initialize(hubic, name) ⇒ Container
Returns a new instance of Container.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hubic/openstack.rb', line 13 def initialize(hubic, name) @hubic = hubic @name = name.dup.freeze j, h = @hubic.api_openstack(:head, @name) @count = h['x-container-object-count'].to_i @bytes = h['x-container-bytes-used' ].to_i @etag = h['etag' ] = Hash[h.map {|k,v| if k =~ /^x-container-meta-(.*)/ [ $1, v ] end }.compact].freeze end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
12 13 14 |
# File 'lib/hubic/openstack.rb', line 12 def bytes @bytes end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
12 13 14 |
# File 'lib/hubic/openstack.rb', line 12 def count @count end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
12 13 14 |
# File 'lib/hubic/openstack.rb', line 12 def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/hubic/openstack.rb', line 12 def name @name end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 |
# File 'lib/hubic/openstack.rb', line 27 def [](key) [key] end |
#destroy! ⇒ Object
35 36 37 38 |
# File 'lib/hubic/openstack.rb', line 35 def destroy! j, h = @hubic.api_openstack(:delete, @name) j end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/hubic/openstack.rb', line 31 def empty? @count == 0 end |
#object(path) ⇒ Object
40 41 |
# File 'lib/hubic/openstack.rb', line 40 def object(path) end |
#objects ⇒ Object
43 44 |
# File 'lib/hubic/openstack.rb', line 43 def objects() end |