Class: Imagemaster3000::Actions::Copy
- Inherits:
-
Object
- Object
- Imagemaster3000::Actions::Copy
- Defined in:
- lib/imagemaster3000/actions/copy.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(source: nil, target: nil, name: nil) ⇒ Copy
constructor
A new instance of Copy.
- #run(image_file) ⇒ Object
Constructor Details
#initialize(source: nil, target: nil, name: nil) ⇒ Copy
Returns a new instance of Copy.
6 7 8 9 10 11 12 13 14 |
# File 'lib/imagemaster3000/actions/copy.rb', line 6 def initialize(source: nil, target: nil, name: nil) raise Imagemaster3000::Errors::ArgumentError, 'neither source nor target can be nil' if source.empty? || target.empty? @filename = source @source = File.join(Imagemaster3000::Settings[:'definitions-dir'], 'files', source) @target = target @name = name logger.debug "Created action #{inspect}" end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
4 5 6 |
# File 'lib/imagemaster3000/actions/copy.rb', line 4 def filename @filename end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/imagemaster3000/actions/copy.rb', line 4 def name @name end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/imagemaster3000/actions/copy.rb', line 4 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
4 5 6 |
# File 'lib/imagemaster3000/actions/copy.rb', line 4 def target @target end |
Instance Method Details
#run(image_file) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/imagemaster3000/actions/copy.rb', line 16 def run(image_file) logger.debug "Running 'copy' action with source #{source.inspect} and target #{target.inspect} on file #{image_file.inspect}" copy image_file rename image_file if name rescue Imagemaster3000::Errors::CommandExecutionError => ex raise Imagemaster3000::Errors::ActionError, ex end |