Class: Pandoku::Formats::ODT

Inherits:
Pandoku::Format show all
Includes:
OutputFormat
Defined in:
lib/pandoku/formats/odt.rb

Overview

ODT (OpenOffice text document) format.

Available Options

:toc

Include an automatically generated table of contents.

Instance Attribute Summary

Attributes inherited from Pandoku::Format

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pandoku::Format

inherited, #initialize

Constructor Details

This class inherits a constructor from Pandoku::Format

Class Method Details

.default_optionsObject



17
18
19
# File 'lib/pandoku/formats/odt.rb', line 17

def self.default_options
  { :toc => false }
end

.nameObject



13
14
15
# File 'lib/pandoku/formats/odt.rb', line 13

def self.name
  :odt
end

Instance Method Details

#clioptsObject



21
22
23
24
# File 'lib/pandoku/formats/odt.rb', line 21

def cliopts
  @tmpfile = @tmpfile || _tmpfile
  super + ["--output=#{@tmpfile}"]
end

#compile(document, file = false) ⇒ Object

Compiles the given document to the format. If a second argument file is true, returns File instead of String.

Note that it creates a temporary file for the result. If file is false, the temporary file become deleted.



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pandoku/formats/odt.rb', line 31

def compile(document, file = false)
  @tmpfile = _tmpfile
  ps = IO.popen(document.command_for(self), 'w')
  ps.print(document.text)
  ps.close
  f = File.new(@tmpfile, 'r')
  return f if file
  result = f.read
  f.close
  File.unlink(@tmpfile)
  return result
end