Class: Kristin::Converter

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

Instance Method Summary collapse

Constructor Details

#initialize(source, target, options = {}) ⇒ Converter

Returns a new instance of Converter.



8
9
10
11
12
# File 'lib/kristin.rb', line 8

def initialize(source, target, options = {})
  @options = options
  @source = source
  @target = target
end

Instance Method Details

#convertObject

Raises:

  • (IOError)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kristin.rb', line 14

def convert
  raise IOError, "Can't find pdf2htmlex executable in PATH" if not command_available?
  src = determine_source(@source)
  opts = process_options.split(" ")
  args = [pdf2htmlex_command, opts, src, @target].flatten
  pid = Spoon.spawnp(*args)
  Process.waitpid(pid)
  
  ## TODO: Grab error message from pdf2htmlex and raise a better error
  raise IOError, "Could not convert #{src}" if $?.exitstatus != 0
end