Class: Bard::Backup::Deleter

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/backup/deleter.rb

Defined Under Namespace

Classes: Filter

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nowObject

Returns the value of attribute now

Returns:

  • (Object)

    the current value of now



7
8
9
# File 'lib/bard/backup/deleter.rb', line 7

def now
  @now
end

#s3_dirObject

Returns the value of attribute s3_dir

Returns:

  • (Object)

    the current value of s3_dir



7
8
9
# File 'lib/bard/backup/deleter.rb', line 7

def s3_dir
  @s3_dir
end

Instance Method Details

#callObject



8
9
10
# File 'lib/bard/backup/deleter.rb', line 8

def call
  s3_dir.delete files_to_delete
end

#files_to_deleteObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bard/backup/deleter.rb', line 12

def files_to_delete
  s3_dir.files.select do |file|
    [
      Filter.new(now, 72, :hours),
      Filter.new(now, 60, :days),
      Filter.new(now, 52, :weeks),
      Filter.new(now, 48, :months),
      Filter.new(now, 100, :years),
    ].all? { |filter| !filter.cover?(file) }
  end
end