class HtmlFromPdf::Converter
Public Class Methods
new(pdf_path, html_path, options = {})
click to toggle source
# File lib/html_from_pdf/converter.rb, line 5 def initialize(pdf_path, html_path, options = {}) @pdf_path = pdf_path @html_path = html_path @options = options end
Public Instance Methods
convert()
click to toggle source
# File lib/html_from_pdf/converter.rb, line 11 def convert file_name = process_html_path command = "pdf2htmlEX #{options} #{@pdf_path} #{file_name}" raise HtmlFromPdf::ConvertingError unless system command end
Private Instance Methods
allowed_options()
click to toggle source
# File lib/html_from_pdf/converter.rb, line 19 def allowed_options yml_path = File.expand_path('../options.yml', __FILE__) YAML.load_file(yml_path) end
options()
click to toggle source
# File lib/html_from_pdf/converter.rb, line 38 def options result = '' @options.each do |key, value| option = allowed_options[key.to_s] raise HtmlFromPdf::UnrecognizedOption.new(key) unless option result += " #{option} #{value}" end result end
process_html_path()
click to toggle source
# File lib/html_from_pdf/converter.rb, line 24 def process_html_path case when @html_path && @options[:dest_dir] file_name = @html_path when @html_path && !@options[:dest_dir] @options[:dest_dir], file_name = File.split(@html_path) when !@html_path && @options[:dest_dir] file_name = nil else @options[:dest_dir], file_name = File.split(default_file_path) end file_name end