class Nifty::TransferMethod
Abstract base class for all trasfer methods
@author Michal Kimle @abstract @attr_reader [String] destination path to destination directory for the transfer method
Attributes
Public Class Methods
Returns backend class supported by the transfer method
@abstract @return [Nifty::Backend] backend class supported by the transfer method
# File lib/nifty/transfer_method.rb, line 32 def backend nil end
Returns textual description of the transfer method Used in help messages.
@abstract @return [String, nil] textual description of the transfer method
# File lib/nifty/transfer_method.rb, line 24 def description nil end
Constructor
@param [String] destination for the transfer method
# File lib/nifty/transfer_method.rb, line 40 def initialize(destination, options={}) @destination = destination @options = options end
Helper method to recognize NIFTY transfer method
@return [TrueClass, FalseClass] whether or not class is a NIFTY transfer method
# File lib/nifty/transfer_method.rb, line 15 def transfer_method? false end
Public Instance Methods
Removes file copy if any created by transfer method
@abstract @param [String] file to be cleaned
# File lib/nifty/transfer_method.rb, line 67 def clean_copy(file) nil end
Removes original file before transfer method
@param [String] file to be cleaned
# File lib/nifty/transfer_method.rb, line 56 def clean_original(file) logger.debug("Deleting files #{file.inspect}") FileUtils.rm file rescue SystemCallError => ex logger.warn("Cannot delete file #{file.inspect}, #{ex.message}") end
Transfers file to the destination
@param [String] file to be transfered @return [String] path to the transfered file
# File lib/nifty/transfer_method.rb, line 49 def transfer(file) fail Nifty::Errors::TransferMethods::ImageFileNotReadableError, "Image file #{file} is not readable" unless File.readable?(file) end