Class: Converter
Instance Method Summary collapse
-
#initialize(mappings) ⇒ Converter
constructor
A new instance of Converter.
- #maybe_convert(file) ⇒ Object
Methods included from Logging
Constructor Details
#initialize(mappings) ⇒ Converter
Returns a new instance of Converter.
7 8 9 10 |
# File 'lib/flickrup/converter.rb', line 7 def initialize(mappings) @mappings = mappings @move_dir = Dir.tmpdir end |
Instance Method Details
#maybe_convert(file) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/flickrup/converter.rb', line 12 def maybe_convert(file) mapping = @mappings[File.extname(file)[1..-1].downcase] if mapping then to_exec = mapping % {:file => file} logger.debug("Running: #{to_exec}") result = system(to_exec) if result logger.info("Removing converted source file #{file}") logger.debug("Moving #{file} to #{@move_dir}") FileUtils.mv(file, @move_dir) else logger.info("Failed to convert source file #{file}") end return result else false end end |