Class: EbsPruneSnapshot::SnapshotAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/ebs_prune_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(snapshots, rotation) ⇒ SnapshotAnalyzer

Returns a new instance of SnapshotAnalyzer.



86
87
88
89
90
91
92
93
# File 'lib/ebs_prune_snapshot.rb', line 86

def initialize(snapshots, rotation)
  @snapshots = snapshots.sort
  @rotation  = rotation
  @to_skip   = []
  @to_delete = []
  @to_save   = {}
  analyze_snapshots
end

Instance Attribute Details

#rotationObject (readonly)

Returns the value of attribute rotation.



84
85
86
# File 'lib/ebs_prune_snapshot.rb', line 84

def rotation
  @rotation
end

#snapshotsObject (readonly)

Returns the value of attribute snapshots.



84
85
86
# File 'lib/ebs_prune_snapshot.rb', line 84

def snapshots
  @snapshots
end

#to_skipObject (readonly)

Returns the value of attribute to_skip.



84
85
86
# File 'lib/ebs_prune_snapshot.rb', line 84

def to_skip
  @to_skip
end

Instance Method Details

#nowObject



103
104
105
# File 'lib/ebs_prune_snapshot.rb', line 103

def now
  @now ||= Time.now.utc
end

#to_deleteObject



99
100
101
# File 'lib/ebs_prune_snapshot.rb', line 99

def to_delete
  snapshots - to_save - to_skip
end

#to_saveObject



95
96
97
# File 'lib/ebs_prune_snapshot.rb', line 95

def to_save
  @to_save.empty? ? [snapshots[-1]] : @to_save.values
end