Class: OpenXml::Docx::Parts::Document
- Inherits:
-
Part
- Object
- Part
- OpenXml::Docx::Parts::Document
- Includes:
- RootNamespaces
- Defined in:
- lib/openxml/docx/parts/document.rb
Constant Summary
Constants included from RootNamespaces
RootNamespaces::POSSIBLE_NAMESPACES
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#current_section ⇒ Object
readonly
Returns the value of attribute current_section.
-
#relationships ⇒ Object
readonly
Returns the value of attribute relationships.
Instance Method Summary collapse
- #<<(child) ⇒ Object
- #background ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #set_section(section) ⇒ Object
- #to_xml ⇒ Object
Methods included from RootNamespaces
Constructor Details
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
7 8 9 |
# File 'lib/openxml/docx/parts/document.rb', line 7 def children @children end |
#current_section ⇒ Object (readonly)
Returns the value of attribute current_section.
7 8 9 |
# File 'lib/openxml/docx/parts/document.rb', line 7 def current_section @current_section end |
#relationships ⇒ Object (readonly)
Returns the value of attribute relationships.
7 8 9 |
# File 'lib/openxml/docx/parts/document.rb', line 7 def relationships @relationships end |
Instance Method Details
#<<(child) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/openxml/docx/parts/document.rb', line 17 def <<(child) if child.is_a?(OpenXml::Docx::Section) set_section(child) else children << child end end |
#background ⇒ Object
34 35 36 |
# File 'lib/openxml/docx/parts/document.rb', line 34 def background @background ||= OpenXml::Docx::Elements::Background.new end |
#set_section(section) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/openxml/docx/parts/document.rb', line 25 def set_section(section) if current_section.nil? @current_section = section else children.last.section_properties = current_section @current_section = section end end |
#to_xml ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/openxml/docx/parts/document.rb', line 38 def to_xml build_xml do |xml| xml.document(root_namespaces) { xml.parent.namespace = :w background.to_xml(xml) unless @background.nil? xml["w"].body { children.each { |child| child.to_xml(xml) } current_section.to_xml(xml) unless current_section.nil? } } end end |