Class: MultiExiftool::Writer

Inherits:
Object
  • Object
show all
Includes:
Executable
Defined in:
lib/multi_exiftool/writer.rb

Overview

Handle writing of metadata via exiftool. Composing the command for the command-line executing it and parsing possible errors.

Instance Attribute Summary collapse

Attributes included from Executable

#config, #errors, #filenames, #numerical

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Executable

#execute

Constructor Details

#initialize(filenames = [], values = {}, opts = {}) ⇒ Writer

Returns a new instance of Writer.



17
18
19
20
# File 'lib/multi_exiftool/writer.rb', line 17

def initialize filenames=[], values={}, opts={}
  super(filenames, opts)
  @values = values
end

Instance Attribute Details

#overwrite_originalObject

Returns the value of attribute overwrite_original.



13
14
15
# File 'lib/multi_exiftool/writer.rb', line 13

def overwrite_original
  @overwrite_original
end

#valuesObject

Returns the value of attribute values.



13
14
15
# File 'lib/multi_exiftool/writer.rb', line 13

def values
  @values
end

Class Method Details

.mandatory_argsObject



22
23
24
# File 'lib/multi_exiftool/writer.rb', line 22

def self.mandatory_args
  %w(-charset FileName=utf8 -charset utf8)
end

Instance Method Details

#exiftool_argsObject

Getting the command-line arguments which would be executed when calling #write. It could be useful for logging, debugging or maybe even for creating a batch-file with exiftool command to be processed.



37
38
39
40
41
42
43
44
45
# File 'lib/multi_exiftool/writer.rb', line 37

def exiftool_args
  fail MultiExiftool::Error, 'No filenames.' if filenames.empty?
  cmd = []
  cmd << Writer.mandatory_args
  cmd << options_args
  cmd << values_args
  cmd << filenames
  cmd.flatten
end

#optionsObject

Options to use with the exiftool command.



27
28
29
30
31
# File 'lib/multi_exiftool/writer.rb', line 27

def options
  opts = super
  opts[:overwrite_original] = true if @overwrite_original
  opts
end