Class: Backup
- Inherits:
-
Object
- Object
- Backup
- Defined in:
- lib/backup_management.rb
Overview
This class represent one backup of “something”
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
One backup refers to the #filepath that contains that backup.
-
#filepath ⇒ Object
readonly
One backup refers to the #filepath that contains that backup.
Instance Method Summary collapse
-
#delete! ⇒ Object
delete that backup (you could need that if the backup is too old).
-
#initialize(filepath) ⇒ Backup
constructor
create one instance of Backup with the #filepath.
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
#date ⇒ Object (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 |
#filepath ⇒ Object (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 |