Class: Woa::Energon::OpenDocumentHelper
- Inherits:
-
Object
- Object
- Woa::Energon::OpenDocumentHelper
- Defined in:
- lib/energon/open_document_helper.rb
Overview
This class is an interface with OpenDocument files. It manages the content of the file so that caller classes just manage xml Objects (ReXml). It’s not possible at this time to work with streams beacause of the zip library (rubyzip), it has to be done via files.
:include: rdoc-header
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(template) ⇒ OpenDocumentHelper
constructor
-
template: the name of the file.
-
-
#save(content) ⇒ Object
Save the file content.xml * content: the xml Object (ReXml).
-
#write ⇒ Object
(also: #close)
Write the final document (the zipfile) and close the file.
Constructor Details
#initialize(template) ⇒ OpenDocumentHelper
-
template: the name of the file
24 25 26 27 28 |
# File 'lib/energon/open_document_helper.rb', line 24 def initialize(template) @zip_file = ZipFile.open(template) @content = xml(read("content.xml")) rescue nil raise InvalidODFDocument if @content.nil? end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
21 22 23 |
# File 'lib/energon/open_document_helper.rb', line 21 def content @content end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/energon/open_document_helper.rb', line 21 def type @type end |
Instance Method Details
#save(content) ⇒ Object
Save the file content.xml
-
content: the xml Object (ReXml)
32 33 34 35 |
# File 'lib/energon/open_document_helper.rb', line 32 def save(content) @content = content save_xml(@content, "content.xml"); end |
#write ⇒ Object Also known as: close
Write the final document (the zipfile) and close the file
38 39 40 |
# File 'lib/energon/open_document_helper.rb', line 38 def write @zip_file.close end |