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

destination[R]
options[R]

Public Class Methods

backend() click to toggle source

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
description() click to toggle source

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
new(destination, options={}) click to toggle source

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
transfer_method?() click to toggle source

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

clean_copy(file) click to toggle source

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
clean_original(file) click to toggle source

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
transfer(file) click to toggle source

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