Class: PdfParadise::SetPdfTitle
- Inherits:
-
Base
- Object
- Base
- PdfParadise::SetPdfTitle
show all
- Defined in:
- lib/pdf_paradise/set_pdf_title.rb
Overview
Constant Summary
collapse
- SHALL_WE_DELETE_THE_ORIGINAL_FILE =
#
SHALL_WE_DELETE_THE_ORIGINAL_FILE
#
true
Constants inherited
from Base
Base::NAMESPACE
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === PdfParadise::SetPdfTitle[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#basename, #be_verbose?, #change_directory, #commandline_arguments?, #copy_file, #delete_file, #e, #ecomment, #esystem, #first_argument?, #gold, #infer_the_namespace, #input_without_leading_hyphens?, #internal_hash?, #is_an_image_file?, #is_on_roebe?, #lightsteelblue, #log_dir?, #mkdir, #mv, #n_pages?, #namespace?, #no_file_at, #opne, #opnn, #orange, #reset_the_internal_hash, #return_commandline_arguments_starting_with_hyphens, #return_files_from_the_commandline_arguments, #return_pwd, #rev, #set_be_quiet, #set_commandline_arguments, #steelblue, #try_to_ensure_that_this_directory_exists, #write_what_into
Constructor Details
#initialize(name_of_the_pdf_file = nil, new_title_to_use = 'Default title', run_already = true) ⇒ SetPdfTitle
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 41
def initialize(
name_of_the_pdf_file = nil,
new_title_to_use = 'Default title',
run_already = true
)
reset
if name_of_the_pdf_file.is_a?(Array) and (name_of_the_pdf_file.size > 1)
new_title_to_use = name_of_the_pdf_file.last
if new_title_to_use.include? '--'
case new_title_to_use when /-?-?set(-|_)?title=(.+)$/
new_title_to_use = $2.to_s.dup
end
end
name_of_the_pdf_file = name_of_the_pdf_file.first
end
set_pdf_file(
name_of_the_pdf_file
)
set_title(new_title_to_use)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
PdfParadise::SetPdfTitle[]
#
192
193
194
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 192
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#add_pdf_file_to_the_commandline ⇒ Object
#
add_pdf_file_to_the_commandline
#
148
149
150
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 148
def add_pdf_file_to_the_commandline
@commandline_to_use << " #{@pdf_file}"
end
|
#add_title_to_the_commandline ⇒ Object
#
add_title_to_the_commandline
#
162
163
164
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 162
def add_title_to_the_commandline
@commandline_to_use << " #{@title}"
end
|
#build_up_commandline_command ⇒ Object
#
build_up_commandline_command
Build up the main commandline to use here.
#
137
138
139
140
141
142
143
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 137
def build_up_commandline_command
if SHALL_WE_DELETE_THE_ORIGINAL_FILE
@commandline_to_use << ' -overwrite_original'
end
add_title_to_the_commandline
add_pdf_file_to_the_commandline
end
|
128
129
130
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 128
def input?
@input
end
|
#pdf_file? ⇒ Boolean
Also known as:
this_file?
155
156
157
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 155
def pdf_file?
@pdf_file
end
|
#reset ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 73
def reset
set_title @commandline_to_use = 'exiftool'.dup @commandline_to_use << ' -charset UTF8'
end
|
#run ⇒ Object
184
185
186
187
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 184
def run
build_up_commandline_command
run_commandline_command
end
|
#run_commandline_command ⇒ Object
#
run_commandline_command
#
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 169
def run_commandline_command
esystem(@commandline_to_use)
end
|
119
120
121
122
123
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 119
def set_input(i = '')
i = i.first if i.is_a? Array
i = i.to_s.dup
@input = i
end
|
#set_pdf_file(i) ⇒ Object
109
110
111
112
113
114
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 109
def set_pdf_file(i)
i = i.first if i.is_a? Array
i = i.to_s i = i.dup if i.frozen?
@pdf_file = i
end
|
#set_title(i = :default) ⇒ Object
#
set_title (title tag)
Assign the title that we will use for the given .pdf file at hand.
#
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/pdf_paradise/set_pdf_title.rb', line 95
def set_title(i = :default)
if i == :default
i = nil
else
i = i.to_s
i = i.dup if i.frozen?
end
i = "-Title=\"#{i}\"" if i
@title = i
end
|