Class: OpenXml::Docx::Parts::Numbering

Inherits:
Part
  • Object
show all
Includes:
RootNamespaces
Defined in:
lib/openxml/docx/parts/numbering.rb

Constant Summary

Constants included from RootNamespaces

RootNamespaces::POSSIBLE_NAMESPACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RootNamespaces

included

Constructor Details

#initializeNumbering

Returns a new instance of Numbering.



11
12
13
14
15
# File 'lib/openxml/docx/parts/numbering.rb', line 11

def initialize
  @abstractNumbers = []
  @numbers = []
  @relationships = OpenXml::Parts::Rels.new
end

Instance Attribute Details

#abstractNumbersObject (readonly)

Returns the value of attribute abstractNumbers.



7
8
9
# File 'lib/openxml/docx/parts/numbering.rb', line 7

def abstractNumbers
  @abstractNumbers
end

#numbersObject (readonly)

Returns the value of attribute numbers.



7
8
9
# File 'lib/openxml/docx/parts/numbering.rb', line 7

def numbers
  @numbers
end

Instance Method Details

#<<(child) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/openxml/docx/parts/numbering.rb', line 17

def <<(child)
  if child.is_a?(OpenXml::Docx::Elements::AbstractNumbering)
    abstractNumbers << child
  elsif child.is_a?(OpenXml::Docx::Elements::Numbering)
    numbers << child
  end
end

#countObject



25
26
27
# File 'lib/openxml/docx/parts/numbering.rb', line 25

def count
  abstractNums.count
end

#to_xmlObject



29
30
31
32
33
34
35
36
37
# File 'lib/openxml/docx/parts/numbering.rb', line 29

def to_xml
  build_standalone_xml do |xml|
    xml.numbering(root_namespaces) {
      xml.parent.namespace = :w
      abstractNumbers.each { |num| num.to_xml(xml) }
      numbers.each { |number| number.to_xml(xml) }
    }
  end
end