Class: MultiExiftool::Reader
- Inherits:
-
Object
- Object
- MultiExiftool::Reader
- 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
-
#group ⇒ Object
Returns the value of attribute group.
-
#tags ⇒ Object
Returns the value of attribute tags.
Attributes included from Executable
#config, #errors, #filenames, #numerical
Class Method Summary collapse
Instance Method Summary collapse
-
#exiftool_args ⇒ Object
Getting the command-line arguments which would be executed when calling #read.
-
#initialize(filenames = [], opts = {}) ⇒ Reader
constructor
A new instance of Reader.
-
#options ⇒ Object
Options to use with the exiftool command.
Methods included from Executable
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
#group ⇒ Object
Returns the value of attribute group.
14 15 16 |
# File 'lib/multi_exiftool/reader.rb', line 14 def group @group end |
#tags ⇒ Object
Returns the value of attribute tags.
14 15 16 |
# File 'lib/multi_exiftool/reader.rb', line 14 def @tags end |
Class Method Details
.mandatory_args ⇒ Object
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_args ⇒ Object
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 << cmd << cmd << filenames cmd.flatten end |
#options ⇒ Object
Options to use with the exiftool command.
36 37 38 39 40 41 42 |
# File 'lib/multi_exiftool/reader.rb', line 36 def opts = super if @group opts["g#@group"] = true end opts end |