Module: Parchment

Defined in:
lib/parchment.rb,
lib/parchment/style.rb,
lib/parchment/helpers.rb,
lib/parchment/version.rb,
lib/parchment/document.rb,
lib/parchment/text_run.rb,
lib/parchment/paragraph.rb,
lib/parchment/formats/odt/odt.rb,
lib/parchment/formats/txt/txt.rb,
lib/parchment/formats/docx/docx.rb,
lib/parchment/formats/odt/style.rb,
lib/parchment/formats/txt/style.rb,
lib/parchment/formats/docx/style.rb,
lib/parchment/formats/odt/document.rb,
lib/parchment/formats/odt/text_run.rb,
lib/parchment/formats/txt/document.rb,
lib/parchment/formats/txt/text_run.rb,
lib/parchment/formats/docx/document.rb,
lib/parchment/formats/docx/text_run.rb,
lib/parchment/formats/odt/paragraph.rb,
lib/parchment/formats/txt/paragraph.rb,
lib/parchment/formats/docx/paragraph.rb

Defined Under Namespace

Modules: DOCX, Helpers, ODT, TXT Classes: Document, MissingFormatterMethodError, Paragraph, Style, TextRun, UnsupportedFileFormatError

Constant Summary collapse

VERSION =
'0.0.2'

Class Method Summary collapse

Class Method Details

.read(path) ⇒ Object

Reads path and determines which format module to use for reading the file.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/parchment.rb', line 11

def self.read(path)
  extension = path.split('.').last
  case extension
  when 'odt'
    Parchment::ODT.read(path)
  when 'docx'
    Parchment::DOCX.read(path)
  when 'txt'
    Parchment::TXT.read(path)
  else
    raise UnsupportedFileFormatError, 'File format is not supported.'
  end
end