Class: Treat::Workers::Formatters::Readers::DOC

Inherits:
Object
  • Object
show all
Defined in:
lib/treat/workers/formatters/readers/doc.rb

Overview

A wrapper for the ‘antiword’ command-line utility.

Class Method Summary collapse

Class Method Details

.read(document, options = {}) ⇒ Object

Extract the readable text from a DOC file using the antiword command-line utility.

Options: none.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/treat/workers/formatters/readers/doc.rb', line 8

def self.read(document, options = {})
  
  f = `antiword #{document.file}`
  f.gsub!("\n\n", '#keep#')
  f.gsub!("\n", ' ')
  f.gsub!('#keep#', "\n\n")
  
  document.value = f
  document.set :format, 'doc'
  document
  
end