class Libis::Format::Converter::PdfMetadata

noinspection DuplicatedCode

Public Class Methods

input_types() click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 14
def self.input_types
  [:PDF]
end
output_types(format = nil) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 18
def self.output_types(format = nil)
  return [] unless input_types.include?(format) if format
  [:PDF]
end

Public Instance Methods

author(v) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 27
def author(v)
  @options[:author] = v.blank? ? nil : v
end
convert(source, target, format, opts = {}) click to toggle source
Calls superclass method Libis::Format::Converter::Base#convert
# File lib/libis/format/converter/pdf_metadata.rb, line 43
def convert(source, target, format, opts = {})
  super

  result = nil

  unless @options.empty?
    result = convert_pdf(source, target)
    return nil unless result
  end

  result

end
convert_pdf(source, target) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 57
def convert_pdf(source, target)

  using_temp(target) do |tmpname|
    result = Libis::Format::Tool::PdfMetadata.run(
        source, tmpname,
        @options.map {|k, v|
          if v.nil?
            nil
          else
            ["--#{k}", v.to_s]
          end}.compact.flatten
    )
    unless result[:err].empty?
      error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
      next nil
    end
    tmpname
  end

end
creator(v) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 31
def creator(v)
  @options[:creator] = v.blank? ? nil : v
end
keywords(v) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 35
def keywords(v)
  @options[:keywords] = v.blank? ? nil : v
end
subject(v) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 39
def subject(v)
  @options[:subject] = v.blank? ? nil : v
end
title(v) click to toggle source
# File lib/libis/format/converter/pdf_metadata.rb, line 23
def title(v)
  @options[:title] = v.blank? ? nil : v
end