Class: DCloud::StorageSnapshot
- Defined in:
- lib/dcloud/storage_snapshot.rb
Instance Attribute Summary
Attributes inherited from BaseModel
Instance Method Summary collapse
-
#initialize(client, uri, xml = nil) ⇒ StorageSnapshot
constructor
A new instance of StorageSnapshot.
- #load_payload(xml = nil) ⇒ Object
- #to_plain ⇒ Object
Methods inherited from BaseModel
attribute, build_reader, #id, xml_tag_name
Constructor Details
#initialize(client, uri, xml = nil) ⇒ StorageSnapshot
Returns a new instance of StorageSnapshot.
39 40 41 |
# File 'lib/dcloud/storage_snapshot.rb', line 39 def initialize(client, uri, xml=nil) super( client, uri, xml ) end |
Instance Method Details
#load_payload(xml = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dcloud/storage_snapshot.rb', line 43 def load_payload(xml=nil) super(xml) unless xml.nil? @created = xml.text( 'created' ) @state = xml.text( 'state' ) storage_volumes = xml.get_elements( 'storage-volume' ) if ( ! storage_volumes.empty? ) storage_volume = storage_volumes.first storage_volume_href = storage_volume.attributes['href'] if ( storage_volume_href ) @storage_volume = StorageVolume.new( @client, storage_volume_href ) end end end end |
#to_plain ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/dcloud/storage_snapshot.rb', line 30 def to_plain sprintf("%-10s | %-15s | %-6s | %15s", self.id[0,10], self.storage_volume.name ? self.storage_volume.name[0, 15] : 'unknown', self.state ? self.state[0,6] : 'unknown', self.created ? self.created[0,15] : 'unknown' ) end |