Class: Pdf2htmlDocker::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf2html_docker/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file, output_file = '', options = {}) ⇒ Service

Returns a new instance of Service.



14
15
16
17
18
19
# File 'lib/pdf2html_docker/service.rb', line 14

def initialize(input_file, output_file = '', options = {})
  @input_dir, @input_file = process_input_file(input_file)
  args = { pdf: @input_file, html: output_file }
  @command_options = OptionBuilder.new(args, options)
  @line = ::Terrapin::CommandLine.new(command, @command_options.to_s)
end

Instance Attribute Details

#commandObject



27
28
29
# File 'lib/pdf2html_docker/service.rb', line 27

def command
  @command ||= "#{DOCKER_COMMAND}  #{@input_dir}#{DOCKER_VOLUME} #{DOCKER_IMAGE} #{BASE_COMMAND}"
end

#command_optionsObject (readonly)

Returns the value of attribute command_options.



11
12
13
# File 'lib/pdf2html_docker/service.rb', line 11

def command_options
  @command_options
end

#input_dirObject (readonly)

Returns the value of attribute input_dir.



11
12
13
# File 'lib/pdf2html_docker/service.rb', line 11

def input_dir
  @input_dir
end

#input_fileObject (readonly)

Returns the value of attribute input_file.



11
12
13
# File 'lib/pdf2html_docker/service.rb', line 11

def input_file
  @input_file
end

#lineObject (readonly)

Returns the value of attribute line.



11
12
13
# File 'lib/pdf2html_docker/service.rb', line 11

def line
  @line
end

Instance Method Details

#runObject



21
22
23
24
25
# File 'lib/pdf2html_docker/service.rb', line 21

def run
  @line.run(@command_options.to_h)
rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError => e
  e
end