class Poleica::Converters::LibreOffice::OptionsGenerator
Generate options for the soffice command
Attributes
format[R]
options[R]
output_path[R]
polei[R]
Public Class Methods
new(polei, options = {}, format = :pdf)
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 33 def initialize(polei, options = {}, format = :pdf) @polei = polei @format = format @output_path = options[:path] || polei.path_with_md5(format) @options = default_options.merge(options) end
Public Instance Methods
default_options()
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 40 def default_options { path: polei.path_with_md5 } end
generate()
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 44 def generate [ default_arguments, format, output_options ].flatten end
temp_path()
click to toggle source
Generate a temp path, and create the file this is needed in order to have the right filename, LibreOffice
just copy the original filename in the choosen directory, it doesn’t accept filename params. @return temp_path
[String]
# File lib/poleica/converters/libre_office.rb, line 56 def temp_path @temp_path ||= generate_temp_path FileUtils.cp(polei.path, @temp_path) unless File.exist?(@temp_path) @temp_path end
Private Instance Methods
default_arguments()
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 77 def default_arguments %w( --nologo --headless --invisible --norestore --nolockcheck --convert-to ) end
generate_temp_path()
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 64 def generate_temp_path if File.directory?(options[:path]) File.join(options[:path], File.basename(polei.path_with_md5)) else pathable_object.path_for_extension(polei.extension) end end
output_options()
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 88 def output_options dir_path = File.dirname(temp_path) ['--outdir', dir_path, temp_path] end
pathable_object()
click to toggle source
# File lib/poleica/converters/libre_office.rb, line 72 def pathable_object pathable_object = Struct.new(:path).new(options[:path]) pathable_object.extend(Poleica::Pathable) end