Class: Libis::Format::Converter::PdfMetadata
- Inherits:
-
Base
show all
- Defined in:
- lib/libis/format/converter/pdf_metadata.rb
Overview
noinspection DuplicatedCode
Instance Attribute Summary
Attributes inherited from Base
#flags, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
category, #check_file_exist, inherited, #initialize, #using_temp, using_temp
Class Method Details
14
15
16
|
# File 'lib/libis/format/converter/pdf_metadata.rb', line 14
def self.input_types
[:PDF]
end
|
.output_types(format = nil) ⇒ Object
18
19
20
21
|
# 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
|
Instance Method Details
#author(v) ⇒ Object
27
28
29
|
# 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 = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# 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) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# 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) ⇒ Object
31
32
33
|
# File 'lib/libis/format/converter/pdf_metadata.rb', line 31
def creator(v)
@options[:creator] = v.blank? ? nil : v
end
|
#keywords(v) ⇒ Object
35
36
37
|
# File 'lib/libis/format/converter/pdf_metadata.rb', line 35
def keywords(v)
@options[:keywords] = v.blank? ? nil : v
end
|
#subject(v) ⇒ Object
39
40
41
|
# File 'lib/libis/format/converter/pdf_metadata.rb', line 39
def subject(v)
@options[:subject] = v.blank? ? nil : v
end
|
23
24
25
|
# File 'lib/libis/format/converter/pdf_metadata.rb', line 23
def title(v)
@options[:title] = v.blank? ? nil : v
end
|