Class: Backup

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

Overview

This class represent one backup of “something”

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ Backup

create one instance of Backup with the #filepath



13
14
15
16
# File 'lib/backup_management.rb', line 13

def initialize(filepath)
	@filepath = filepath
	@date = Date.strptime(filepath[/\d{8}T\d{4}/],'%Y%m%dT%H%M')
end

Instance Attribute Details

#dateObject (readonly)

One backup refers to the #filepath that contains that backup. That file has to be represented by #name_of_something_##date The #date has to be represented this way : %Y%m%dT%H%M



10
11
12
# File 'lib/backup_management.rb', line 10

def date
  @date
end

#filepathObject (readonly)

One backup refers to the #filepath that contains that backup. That file has to be represented by #name_of_something_##date The #date has to be represented this way : %Y%m%dT%H%M



10
11
12
# File 'lib/backup_management.rb', line 10

def filepath
  @filepath
end

Instance Method Details

#delete!Object

delete that backup (you could need that if the backup is too old)



19
20
21
22
# File 'lib/backup_management.rb', line 19

def delete!
puts "#{filepath} deleted."
 File.delete(filepath)
end