Class: Poleica::Converters::LibreOffice

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/poleica/converters/libre_office.rb

Overview

The LibreOffice converter, use the ‘soffice’ command to convert documents

Defined Under Namespace

Classes: OptionsGenerator

Constant Summary collapse

COMPATIBLE_TYPES =
[
  Types::Document
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#bin_path, exec_with_timeout, extract_extension_and_options, fail_if_error, #host_os, init_process_std, #linux?, map_std, #osx?, #underscorize, #windows?

Constructor Details

#initialize(polei) ⇒ LibreOffice

Returns a new instance of LibreOffice.



16
17
18
# File 'lib/poleica/converters/libre_office.rb', line 16

def initialize(polei)
  @polei = polei
end

Instance Attribute Details

#poleiObject (readonly)

Returns the value of attribute polei.



14
15
16
# File 'lib/poleica/converters/libre_office.rb', line 14

def polei
  @polei
end

Instance Method Details

#to_pdf(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/poleica/converters/libre_office.rb', line 20

def to_pdf(options = {})
  opts_gen = OptionsGenerator.new(polei, options, :pdf)
  exec_with_timeout(bin_path, opts_gen.generate)
  expected_file_path = opts_gen.output_path
  File.exist?(expected_file_path) ? expected_file_path : nil
ensure
  temp_file_path = opts_gen.temp_path
  File.delete(temp_file_path) if File.exist?(temp_file_path)
end