Class: Docxtor::Document::Builder
- Inherits:
-
Object
- Object
- Docxtor::Document::Builder
- Defined in:
- lib/docxtor/document/builder.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
- #render(&block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Builder
Returns a new instance of Builder.
6 7 8 |
# File 'lib/docxtor/document/builder.rb', line 6 def initialize(&block) @content = render(&block) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/docxtor/document/builder.rb', line 4 def content @content end |
Instance Method Details
#render(&block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/docxtor/document/builder.rb', line 10 def render(&block) 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 << Document::Root.new(&block).render(xml) end end xml.target! end |