Class: S33r::S3Object
- Inherits:
-
Object
- Object
- S33r::S3Object
- Defined in:
- lib/s33r/bucket_listing.rb
Overview
Representation of an object stored in a bucket.
Instance Attribute Summary collapse
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#last_modified ⇒ Object
readonly
Returns the value of attribute last_modified.
-
#named_bucket ⇒ Object
Returns the value of attribute named_bucket.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#storage_class ⇒ Object
readonly
Returns the value of attribute storage_class.
Instance Method Summary collapse
-
#delete ⇒ Object
Remove this object from associated NamedBucket.
-
#initialize(node = nil, named_bucket = nil) ⇒ S3Object
constructor
Create from a node.
-
#set_from_node(doc) ⇒ Object
Set properties of the object from an XML document.
-
#set_from_xml_string(xml_str) ⇒ Object
Set properties of the object from an XML string.
Constructor Details
#initialize(node = nil, named_bucket = nil) ⇒ S3Object
Create from a node.
105 106 107 108 |
# File 'lib/s33r/bucket_listing.rb', line 105 def initialize(node=nil, named_bucket=nil) @named_bucket = named_bucket self.set_from_node(node) unless node.nil? end |
Instance Attribute Details
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def etag @etag end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def key @key end |
#last_modified ⇒ Object (readonly)
Returns the value of attribute last_modified.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def last_modified @last_modified end |
#named_bucket ⇒ Object
Returns the value of attribute named_bucket.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def named_bucket @named_bucket end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def owner @owner end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def size @size end |
#storage_class ⇒ Object (readonly)
Returns the value of attribute storage_class.
101 102 103 |
# File 'lib/s33r/bucket_listing.rb', line 101 def storage_class @storage_class end |
Instance Method Details
#delete ⇒ Object
Remove this object from associated NamedBucket.
111 112 113 |
# File 'lib/s33r/bucket_listing.rb', line 111 def delete @named_bucket.delete_key(@key) unless @named_bucket.nil? end |
#set_from_node(doc) ⇒ Object
Set properties of the object from an XML document.
doc
: XML::Document instance to parse to get properties for this object.
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/s33r/bucket_listing.rb', line 126 def set_from_node(doc) @key = doc.xget('Key') @last_modified = DateTime.parse(doc.xget('LastModified')) @etag = doc.xget('ETag').gsub("\"", "") @size = doc.xget('Size').to_i @owner = S3User.new(doc.find('Owner').to_a.first) # TODO: if setting from a full object listing (GET on a resource key), # do additional field setting here (e.g. x-amz-meta- headers) # and assign the response body to some data field; detect whether # these fields exist before attempting to set properties end |
#set_from_xml_string(xml_str) ⇒ Object
Set properties of the object from an XML string.
xml_str
should be a string representing a full XML document, containing a <Contents> element as its root element.
119 120 121 |
# File 'lib/s33r/bucket_listing.rb', line 119 def set_from_xml_string(xml_str) set_from_node(XML.get_xml_doc(xml_str)) end |