Class: Nifty::TransferMethod Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/nifty/transfer_method.rb

Overview

This class is abstract.

Abstract base class for all trasfer methods

Author:

  • Michal Kimle

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(destination) ⇒ TransferMethod

Constructor

Parameters:

  • destination (String)

    for the transfer method



40
41
42
# File 'lib/nifty/transfer_method.rb', line 40

def initialize(destination)
  @destination = destination
end

Instance Attribute Details

#destinationString (readonly)

path to destination directory for the transfer method

Returns:

  • (String)

    the current value of destination



8
9
10
# File 'lib/nifty/transfer_method.rb', line 8

def destination
  @destination
end

Class Method Details

.backendNifty::Backend

This method is abstract.

Returns backend class supported by the transfer method

Returns:



32
33
34
# File 'lib/nifty/transfer_method.rb', line 32

def backend
  nil
end

.descriptionString?

This method is abstract.

Returns textual description of the transfer method Used in help messages.

Returns:

  • (String, nil)

    textual description of the transfer method



24
25
26
# File 'lib/nifty/transfer_method.rb', line 24

def description
  nil
end

.transfer_method?TrueClass, FalseClass

Helper method to recognize NIFTY transfer method

Returns:

  • (TrueClass, FalseClass)

    whether or not class is a NIFTY transfer method



15
16
17
# File 'lib/nifty/transfer_method.rb', line 15

def transfer_method?
  false
end

Instance Method Details

#clean_copy(file) ⇒ Object

This method is abstract.

Removes file copy if any created by transfer method

Parameters:

  • file (String)

    to be cleaned



66
67
68
# File 'lib/nifty/transfer_method.rb', line 66

def clean_copy(file)
  nil
end

#clean_original(file) ⇒ Object

Removes original file before transfer method

Parameters:

  • file (String)

    to be cleaned



55
56
57
58
59
60
# File 'lib/nifty/transfer_method.rb', line 55

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) ⇒ String

Transfers file to the destination

Parameters:

  • file (String)

    to be transfered

Returns:

  • (String)

    path to the transfered file



48
49
50
# File 'lib/nifty/transfer_method.rb', line 48

def transfer(file)
  fail Nifty::Errors::TransferMethods::ImageFileNotReadableError, "Image file #{file} is not readable" unless File.readable?(file)
end