Class: Backup
- Inherits:
-
Object
- Object
- Backup
- Defined in:
- lib/bakman/backup.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.
-
#to_keep ⇒ Object
Returns the value of attribute to_keep.
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
15 16 17 18 19 |
# File 'lib/bakman/backup.rb', line 15 def initialize(filepath) @filepath = filepath @date = Date.strptime(filepath[/\d{8}T\d{4}/],'%Y%m%dT%H%M') @to_keep = false 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
11 12 13 |
# File 'lib/bakman/backup.rb', line 11 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
11 12 13 |
# File 'lib/bakman/backup.rb', line 11 def filepath @filepath end |
#to_keep ⇒ Object
Returns the value of attribute to_keep.
12 13 14 |
# File 'lib/bakman/backup.rb', line 12 def to_keep @to_keep end |
Instance Method Details
#delete! ⇒ Object
delete that backup (you could need that if the backup is too old)
22 23 24 25 |
# File 'lib/bakman/backup.rb', line 22 def delete! puts "#{filepath} deleted." File.delete(filepath) end |