Class: IML::FileMover
- Inherits:
-
Object
- Object
- IML::FileMover
- Defined in:
- lib/iml/file_mover.rb
Instance Method Summary collapse
- #call(source_path, media, format: nil, target: nil, pretend: false) ⇒ Object
-
#initialize(formatter: IML::Formatter.new) ⇒ FileMover
constructor
A new instance of FileMover.
Constructor Details
Instance Method Details
#call(source_path, media, format: nil, target: nil, pretend: false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/iml/file_mover.rb', line 8 def call(source_path, media, format: nil, target: nil, pretend: false) dest = @formatter.pathname(media, format: format, target: target) unless pretend FileUtils.mkdir_p(dest.dirname) FileUtils.mv(source_path.to_s, dest.to_s) end dest rescue Errno::ENOENT => e raise IML::FileNotFoundError, e. end |