Module: Swordfish

Defined in:
lib/swordfish/document.rb,
lib/swordfish.rb,
lib/swordfish/nodes/raw.rb,
lib/swordfish/nodes/base.rb,
lib/swordfish/nodes/list.rb,
lib/swordfish/nodes/text.rb,
lib/swordfish/stylesheet.rb,
lib/swordfish/nodes/image.rb,
lib/swordfish/nodes/table.rb,
lib/swordfish/nodes/header.rb,
lib/swordfish/nodes/footnote.rb,
lib/swordfish/nodes/hyperlink.rb,
lib/swordfish/nodes/linebreak.rb,
lib/swordfish/nodes/list_item.rb,
lib/swordfish/nodes/paragraph.rb,
lib/swordfish/nodes/table_row.rb,
lib/swordfish/nodes/table_cell.rb,
lib/swordfish/formats/docx/parser.rb,
lib/swordfish/formats/docx/document.rb

Overview

Swordfish::DOCX defines a parser for .docx (Office OpenXML) formats

Defined Under Namespace

Modules: DOCX, Node Classes: Document, Stylesheet, UnsupportedFormatError

Class Method Summary collapse

Class Method Details

.open(filepath, opts = {}) ⇒ Object

Main entry point into the parser. Pass in a filepath and return a parsed document.



7
8
9
10
11
12
13
14
15
# File 'lib/swordfish.rb', line 7

def self.open(filepath, opts={})
  extension = (opts[:extension] || filepath.split('.').last).downcase.to_sym
  case extension
    when :docx
      Swordfish::DOCX::Document.open(filepath)
    else
      raise UnsupportedFormatError, "'#{extension}' is not a recognized file format"
  end
end