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, options = {}) ⇒ TransferMethod

Constructor

Parameters:

  • destination (String)

    for the transfer method



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

def initialize(destination, options={})
  @destination = destination
  @options = options
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

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
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



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

def clean_copy(file)
  nil
end

#clean_original(file) ⇒ Object

Removes original file before transfer method

Parameters:

  • file (String)

    to be cleaned



56
57
58
59
60
61
# 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) ⇒ String

Transfers file to the destination

Parameters:

  • file (String)

    to be transfered

Returns:

  • (String)

    path to the transfered file



49
50
51
# 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