Class: Blobsterix::Storage::Bucket
- Inherits:
-
Object
- Object
- Blobsterix::Storage::Bucket
- Defined in:
- lib/blobsterix/storage/bucket.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#creation_date ⇒ Object
Returns the value of attribute creation_date.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, date) {|_self| ... } ⇒ Bucket
constructor
A new instance of Bucket.
- #insert_xml(xml) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(name, date) {|_self| ... } ⇒ Bucket
Returns a new instance of Bucket.
5 6 7 8 9 10 |
# File 'lib/blobsterix/storage/bucket.rb', line 5 def initialize(name, date) @name = name @creation_date = date @contents = [] yield self if block_given? end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
4 5 6 |
# File 'lib/blobsterix/storage/bucket.rb', line 4 def contents @contents end |
#creation_date ⇒ Object
Returns the value of attribute creation_date.
4 5 6 |
# File 'lib/blobsterix/storage/bucket.rb', line 4 def creation_date @creation_date end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/blobsterix/storage/bucket.rb', line 4 def name @name end |
Instance Method Details
#insert_xml(xml) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/blobsterix/storage/bucket.rb', line 28 def insert_xml(xml) xml.Bucket{ xml.Name name xml.CreationDate creation_date } end |
#to_xml ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/blobsterix/storage/bucket.rb', line 11 def to_xml() date = Date.today xml = Nokogiri::XML::Builder.new do |xml| xml.ListBucketResult(:xmlns => "http://doc.s3.amazonaws.com/#{date.year}-#{date.month}-#{date.day}") { xml.Name name xml.Prefix xml.Marker xml.MaxKeys 1000 xml.IsTruncated false contents.each{|entry| entry.insert_xml(xml) } } end xml.to_xml end |