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, Nifty::TransferMethods::Opennebula::Scp
Instance Attribute Summary collapse
-
#destination ⇒ String
readonly
path to destination directory for the transfer method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
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, options = {}) ⇒ TransferMethod
constructor
Constructor.
-
#transfer(file) ⇒ String
Transfers file to the destination.
Constructor Details
#initialize(destination, options = {}) ⇒ TransferMethod
Constructor
40 41 42 43 |
# File 'lib/nifty/transfer_method.rb', line 40 def initialize(destination, ={}) @destination = destination @options = 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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/nifty/transfer_method.rb', line 9 def @options 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
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
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.}") end |
#transfer(file) ⇒ String
Transfers file to the destination
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 |