Class: Bak::BackupNameGenerator
- Inherits:
-
Object
- Object
- Bak::BackupNameGenerator
- Defined in:
- lib/bak/backup_name_generator.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #[](item) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(filename, options_hash) ⇒ BackupNameGenerator
constructor
A new instance of BackupNameGenerator.
- #start ⇒ Object
Constructor Details
#initialize(filename, options_hash) ⇒ BackupNameGenerator
Returns a new instance of BackupNameGenerator.
5 6 7 8 |
# File 'lib/bak/backup_name_generator.rb', line 5 def initialize(filename, ) @filename = filename @options = end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
3 4 5 |
# File 'lib/bak/backup_name_generator.rb', line 3 def filename @filename end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/bak/backup_name_generator.rb', line 3 def @options end |
Instance Method Details
#[](item) ⇒ Object
10 11 12 |
# File 'lib/bak/backup_name_generator.rb', line 10 def [](item) @options[item] end |
#[]=(k, v) ⇒ Object
14 15 16 |
# File 'lib/bak/backup_name_generator.rb', line 14 def []=(k, v) @options[k] = v end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bak/backup_name_generator.rb', line 18 def start filename = @filename if @options != {} if @options[:date] then filename = _with_date(filename) end if @options[:postfix] then filename = _with_postfix(filename, @options[:postfix]) end if @options[:prefix] then filename = _with_prefix(filename, @options[:prefix]) end if @options[:replace] then filename = _with_replace(filename, @options[:replace]) end if @options[:target_path] then filename = _with_target_path(filename, @options[:target_path]) end end unless @options[:no_bak] then filename = "#{filename}.bak" end filename end |