Class: MultiExiftool::Reader

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

Overview

Handle reading of metadata via exiftool. Composing the command for the command-line executing it and parsing the results as well as 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 = [], opts = {}) ⇒ Reader

Returns a new instance of Reader.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/multi_exiftool/reader.rb', line 18

def initialize filenames=[], opts={}
  super(filenames, opts)
  if val = opts.delete(:tags)
    @tags = val
  else
    @tags = []
  end
  if val = opts.delete(:group)
    @group = val
  end
  @options = opts unless opts.empty?
end

Instance Attribute Details

#groupObject

Returns the value of attribute group.



14
15
16
# File 'lib/multi_exiftool/reader.rb', line 14

def group
  @group
end

#tagsObject

Returns the value of attribute tags.



14
15
16
# File 'lib/multi_exiftool/reader.rb', line 14

def tags
  @tags
end

Class Method Details

.mandatory_argsObject



31
32
33
# File 'lib/multi_exiftool/reader.rb', line 31

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

Instance Method Details

#exiftool_argsObject

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



48
49
50
51
52
53
54
55
56
# File 'lib/multi_exiftool/reader.rb', line 48

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

#optionsObject

Options to use with the exiftool command.



36
37
38
39
40
41
42
# File 'lib/multi_exiftool/reader.rb', line 36

def options
  opts = super
  if @group
    opts["g#@group"] = true
  end
  opts
end