Class: Nifty::TransferMethod Abstract
- Inherits:
-
Object
- Object
- Nifty::TransferMethod
- Defined in:
- lib/nifty/transfer_method.rb
Overview
Abstract base class for all trasfer methods
Direct Known Subclasses
Nifty::TransferMethods::Opennebula::Cp, Nifty::TransferMethods::Opennebula::Noop
Instance Attribute Summary collapse
-
#destination ⇒ String
readonly
path to destination directory for the transfer method.
Class Method Summary collapse
-
.backend ⇒ Nifty::Backend
abstract
Returns backend class supported by the transfer method.
-
.description ⇒ String?
abstract
Returns textual description of the transfer method Used in help messages.
-
.transfer_method? ⇒ TrueClass, FalseClass
Helper method to recognize NIFTY transfer method.
Instance Method Summary collapse
-
#clean_copy(file) ⇒ Object
abstract
Removes file copy if any created by transfer method.
-
#clean_original(file) ⇒ Object
Removes original file before transfer method.
-
#initialize(destination) ⇒ TransferMethod
constructor
Constructor.
-
#transfer(file) ⇒ String
Transfers file to the destination.
Constructor Details
#initialize(destination) ⇒ TransferMethod
Constructor
40 41 42 |
# File 'lib/nifty/transfer_method.rb', line 40 def initialize(destination) @destination = destination end |
Instance Attribute Details
#destination ⇒ String (readonly)
path to destination directory for the transfer method
8 9 10 |
# File 'lib/nifty/transfer_method.rb', line 8 def destination @destination end |
Class Method Details
.backend ⇒ Nifty::Backend
Returns backend class supported by the transfer method
32 33 34 |
# File 'lib/nifty/transfer_method.rb', line 32 def backend nil end |
.description ⇒ String?
Returns textual description of the transfer method Used in help messages.
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
15 16 17 |
# File 'lib/nifty/transfer_method.rb', line 15 def transfer_method? false end |
Instance Method Details
#clean_copy(file) ⇒ Object
Removes file copy if any created by transfer method
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
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.}") end |
#transfer(file) ⇒ String
Transfers file to the destination
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 |