Class: Aebus::EC2::Snapshot
- Inherits:
-
Object
- Object
- Aebus::EC2::Snapshot
- Defined in:
- lib/ec2/snapshot.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#volume_id ⇒ Object
readonly
Returns the value of attribute volume_id.
Instance Method Summary collapse
- #aebus_removable_snapshot? ⇒ Boolean
- #aebus_snapshot? ⇒ Boolean
- #aebus_tags ⇒ Object
- #aebus_tags_include?(label) ⇒ Boolean
-
#initialize(hash) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #keep=(value) ⇒ Object
- #keep? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ Snapshot
Returns a new instance of Snapshot.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ec2/snapshot.rb', line 16 def initialize(hash) raise(ArgumentError,"hash cannot be nil") unless hash @keep @id = hash.snapshotId @start_time = Time.parse(hash.startTime) @volume_id = hash.volumeId @tags = Hash.new if (hash.tagSet) then tag_array = hash.tagSet.item tag_array.each do |tag| @tags.store(tag["key"],tag["value"]) end end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/ec2/snapshot.rb', line 14 def id @id end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
14 15 16 |
# File 'lib/ec2/snapshot.rb', line 14 def start_time @start_time end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
14 15 16 |
# File 'lib/ec2/snapshot.rb', line 14 def @tags end |
#volume_id ⇒ Object (readonly)
Returns the value of attribute volume_id.
14 15 16 |
# File 'lib/ec2/snapshot.rb', line 14 def volume_id @volume_id end |
Instance Method Details
#aebus_removable_snapshot? ⇒ Boolean
47 48 49 50 |
# File 'lib/ec2/snapshot.rb', line 47 def aebus_removable_snapshot? return false unless aebus_snapshot? ( & [AEBUS_MANUAL_TAG, AEBUS_KEEP_TAG]).count == 0 end |
#aebus_snapshot? ⇒ Boolean
43 44 45 |
# File 'lib/ec2/snapshot.rb', line 43 def aebus_snapshot? @tags.include?(AEBUS_TAG) end |
#aebus_tags ⇒ Object
52 53 54 |
# File 'lib/ec2/snapshot.rb', line 52 def @tags[AEBUS_TAG].split(',') end |
#aebus_tags_include?(label) ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/ec2/snapshot.rb', line 36 def (label) if aebus_snapshot? then return .include? label end false end |
#keep=(value) ⇒ Object
56 57 58 |
# File 'lib/ec2/snapshot.rb', line 56 def keep= value @keep = value end |
#keep? ⇒ Boolean
60 61 62 |
# File 'lib/ec2/snapshot.rb', line 60 def keep? @keep end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/ec2/snapshot.rb', line 32 def to_s "{snapshot_id => #{@id}, volume_id => #{@volume_id}, start_time => #{@start_time}, tags => #{@tags} " end |