Class: BackupOrganizer::Configuration
- Inherits:
-
Object
- Object
- BackupOrganizer::Configuration
- Defined in:
- lib/backup_organizer/configuration.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #directories ⇒ Object
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
- #move_all_files ⇒ Object
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 11 |
# File 'lib/backup_organizer/configuration.rb', line 6 def initialize() @path, @pattern = [:path], [:pattern] raise Error::ConfigurationError.new('No path set') unless @path raise Error::ConfigurationError.new('No pattern set') unless @path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/backup_organizer/configuration.rb', line 5 def path @path end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/backup_organizer/configuration.rb', line 5 def pattern @pattern end |
Instance Method Details
#directories ⇒ Object
13 14 15 |
# File 'lib/backup_organizer/configuration.rb', line 13 def directories pattern.directories.map {|directory| File.("./#{directory}", @path)} end |
#move_all_files ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/backup_organizer/configuration.rb', line 17 def move_all_files sources = directories destinations = (directories << :delete)[1..-1] sources.each_with_index do |source, i| FileMover.move_files(source, @pattern.rules[i], destinations[i]) end end |