Class: OoxmlParser::Numbering
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Numbering
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/numbering.rb
Overview
Class for data of Numbering
Instance Attribute Summary collapse
-
#abstract_numbering_list ⇒ Array, AbstractNumbering
Abstract numbering list.
-
#numbering_definition_list ⇒ Array, NumberingDefinition
Numbering definition list.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ Numbering
constructor
A new instance of Numbering.
-
#parse ⇒ Numbering
Parse Numbering data.
-
#properties_by_num_id(num_id) ⇒ nil, AbstractNumbering
Get properties by number id.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ Numbering
Returns a new instance of Numbering.
14 15 16 17 18 |
# File 'lib/ooxml_parser/docx_parser/document_structure/numbering.rb', line 14 def initialize(parent: nil) @abstract_numbering_list = [] @numbering_definition_list = [] super end |
Instance Attribute Details
#abstract_numbering_list ⇒ Array, AbstractNumbering
Returns abstract numbering list.
10 11 12 |
# File 'lib/ooxml_parser/docx_parser/document_structure/numbering.rb', line 10 def abstract_numbering_list @abstract_numbering_list end |
#numbering_definition_list ⇒ Array, NumberingDefinition
Returns numbering definition list.
12 13 14 |
# File 'lib/ooxml_parser/docx_parser/document_structure/numbering.rb', line 12 def numbering_definition_list @numbering_definition_list end |
Instance Method Details
#parse ⇒ Numbering
Parse Numbering data
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ooxml_parser/docx_parser/document_structure/numbering.rb', line 40 def parse numbering_xml = "#{root_object.unpacked_folder}word/numbering.xml" return nil unless File.exist?(numbering_xml) node = parse_xml(numbering_xml) node.xpath('w:numbering/*').each do |numbering_child_node| case numbering_child_node.name when 'abstractNum' @abstract_numbering_list << AbstractNumbering.new(parent: self).parse(numbering_child_node) when 'num' @numbering_definition_list << NumberingDefinition.new(parent: self).parse(numbering_child_node) end end self end |
#properties_by_num_id(num_id) ⇒ nil, AbstractNumbering
Get properties by number id
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ooxml_parser/docx_parser/document_structure/numbering.rb', line 23 def properties_by_num_id(num_id) abstract_num_id = nil @numbering_definition_list.each do |num_def| next unless num_id == num_def.id abstract_num_id = num_def.abstract_numbering_id.value break end return nil if abstract_num_id.nil? @abstract_numbering_list.each do |abstract_num_item| return abstract_num_item if abstract_num_id == abstract_num_item.id end end |