Module: DocumentToRichHtml

Defined in:
lib/document_to_rich_html.rb,
lib/document_to_rich_html/version.rb,
lib/document_to_rich_html/docx_patch.rb,
lib/document_to_rich_html/pdf_converter.rb,
lib/document_to_rich_html/html_formatter.rb,
lib/document_to_rich_html/security_utils.rb,
lib/document_to_rich_html/word_converter.rb,
lib/document_to_rich_html/excel_converter.rb,
lib/document_to_rich_html/image_converter.rb

Overview

Converts documents to rich HTML format

Defined Under Namespace

Modules: DocxPatch, SecurityUtils Classes: Error, ExcelConverter, HtmlFormatter, ImageConverter, PdfConverter, WordConverter

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.convert(file_path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/document_to_rich_html.rb', line 17

def self.convert(file_path)
  SecurityUtils.validate_file(file_path)
  extension = File.extname(file_path).downcase
  case extension
  when '.pdf'
    PdfConverter.convert(file_path)
  when '.docx', '.doc'
    WordConverter.convert(file_path)
  when '.xlsx', '.xls'
    ExcelConverter.convert(file_path)
  when '.jpg', '.jpeg', '.png', '.gif', '.svg'
    ImageConverter.convert(file_path)
  else
    raise Error, "Unsupported file format: #{extension}"
  end
end