module MultiExiftool::Executable

Mixin for Reader and Writer.

Attributes

errors[R]
filenames[RW]
numerical[RW]
options[RW]

Public Class Methods

new(filenames=[], options={}) click to toggle source
# File lib/multi_exiftool/executable.rb, line 14
def initialize filenames=[], options={}
  @options = options
  @filenames = filenames
  @option_mapping = {numerical: :n}
end

Public Instance Methods

filenames=(value) click to toggle source
# File lib/multi_exiftool/executable.rb, line 26
def filenames= value
  @filenames = Array(value)
end

Private Instance Methods

execute_command() click to toggle source
# File lib/multi_exiftool/executable.rb, line 59
def execute_command
  stdin, @stdout, @stderr = Open3.popen3(exiftool_command, '-@', '-')
  exiftool_args.each do |part|
    stdin << part
    stdin << "\n"
  end
  stdin.close
end
exiftool_command() click to toggle source
# File lib/multi_exiftool/executable.rb, line 38
def exiftool_command
  MultiExiftool.exiftool_command
end
options_args() click to toggle source
# File lib/multi_exiftool/executable.rb, line 42
def options_args
  opts = options
  return [] if opts.empty?
  opts.map do |opt, val|
    arg = @option_mapping[opt] || opt
    if val == true
      "-#{arg}"
    else
      %W[-#{arg} #{val}]
    end
  end
end
prepare_execution() click to toggle source
# File lib/multi_exiftool/executable.rb, line 55
def prepare_execution
  @errors = []
end