Class: Pandoku::Document
- Inherits:
-
Object
- Object
- Pandoku::Document
- Defined in:
- lib/pandoku/document.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#command_for(format) ⇒ Object
Makes a command string to execute Pandoc.
-
#compile(format, io = false) ⇒ Object
Compiles the document to given
format
. -
#initialize(format, text) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(format, text) ⇒ Document
Returns a new instance of Document.
9 10 11 12 13 14 15 |
# File 'lib/pandoku/document.rb', line 9 def initialize(format, text) unless format.is_a?(InputFormat) raise TypeError, 'format must be InputFormat' end @format = format @text = text end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
7 8 9 |
# File 'lib/pandoku/document.rb', line 7 def format @format end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/pandoku/document.rb', line 7 def text @text end |
Instance Method Details
#command_for(format) ⇒ Object
Makes a command string to execute Pandoc.
18 19 20 21 22 23 24 25 |
# File 'lib/pandoku/document.rb', line 18 def command_for(format) <<-CMD #{PANDOC_PATH} -f #{self.format.class.name} -t #{format.class.name} #{self.format.cliopts} #{format.cliopts} CMD end |
#compile(format, io = false) ⇒ Object
Compiles the document to given format
. If a second argument io
is true, returns IO
instead of String
.
29 30 31 32 33 34 |
# File 'lib/pandoku/document.rb', line 29 def compile(format, io = false) unless format.is_a?(OutputFormat) raise TypeError, 'format must be OutputFormat' end format.compile(self, io) end |