Class: Blobsterix::Storage::Bucket

Inherits:
Object
  • Object
show all
Defined in:
lib/blobsterix/storage/bucket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, date) {|_self| ... } ⇒ Bucket

Returns a new instance of Bucket.

Yields:

  • (_self)

Yield Parameters:



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

#contentsObject

Returns the value of attribute contents.



4
5
6
# File 'lib/blobsterix/storage/bucket.rb', line 4

def contents
  @contents
end

#creation_dateObject

Returns the value of attribute creation_date.



4
5
6
# File 'lib/blobsterix/storage/bucket.rb', line 4

def creation_date
  @creation_date
end

#nameObject

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_xmlObject



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