Class: Docxtor2::Package::Document
- Defined in:
- lib/docxtor2.rb,
lib/docxtor2/package/document.rb
Defined Under Namespace
Classes: Element, Heading, PageBreak, Paragraph, TableOfContents
Instance Attribute Summary
Attributes inherited from Part
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content, filepath = DOCUMENT_XML_PATH) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(content, filepath = DOCUMENT_XML_PATH) ⇒ Document
Returns a new instance of Document.
3 4 5 |
# File 'lib/docxtor2/package/document.rb', line 3 def initialize(content, filepath = DOCUMENT_XML_PATH) super(filepath, self.class.render(content)) end |
Class Method Details
.render(content) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/docxtor2/package/document.rb', line 7 def self.render(content) xml = Builder::XmlMarkup.new xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8", :standalone => "yes" xml.w :document, "xmlns:ve" => "http://schemas.openxmlformats.org/markup-compatibility/2006", "xmlns:o" => "urn:schemas-microsoft-com:office:office", "xmlns:r" => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", "xmlns:m" => "http://schemas.openxmlformats.org/officeDocument/2006/math", "xmlns:v" => "urn:schemas-microsoft-com:vml", "xmlns:wp" => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "xmlns:w10" => "urn:schemas-microsoft-com:office:word", "xmlns:w" => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "xmlns:wne" => "http://schemas.microsoft.com/office/word/2006/wordml" do xml.w :body do xml << content end end xml.target! end |