class Pdftotext::CLI

Constants

DEFAULT_OPTIONS

Public Instance Methods

run_command(*args) click to toggle source
# File lib/pdftotext/cli.rb, line 8
def run_command(*args)
  options = DEFAULT_OPTIONS.merge(args.pop)
  args = args.concat options_to_args(options)
  output, status = Open3.capture2e(bin_path, *args)
  raise "Command `#{bin_path} #{args.join(" ")}` failed: #{output}" if status.exitstatus != 0
  output
end

Private Instance Methods

bin_path() click to toggle source
# File lib/pdftotext/cli.rb, line 18
def bin_path
  @bin_path ||= Cliver.detect!('pdftotext')
end
options_to_args(options) click to toggle source
# File lib/pdftotext/cli.rb, line 22
def options_to_args(options)
  args = []
  options.each do |key, value|
    next if value === false
    args.push "-#{key}"
    args.push value.to_s unless value === true
  end
  args
end