Sha256: 227e91a2b0765c4973809681a31cee46ec40fe53cd3892cc70085eba2a1d3a8c

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

module OoxmlParser
  class HeaderFooter < OOXMLDocumentObject
    attr_accessor :id, :description, :type

    def initialize(type = :header)
      @type = type
    end

    def parse(type, id, default_paragraph, default_character)
      if type == :header
        doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/footnotes.xml'))
        doc.search('//w:footnote').each do |footnote|
          next unless footnote.attribute('id').value == id
          description = []
          paragraph_number = 0
          footnote.xpath('w:p').each do |paragraph|
            description << DocxParagraph.parse(paragraph, paragraph_number, default_paragraph, default_character)
            paragraph_number += 1
          end
          return description
        end
      elsif type == :header
        doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/endnotes.xml'))
        doc.search('//w:endnote').each do |footnote|
          next unless footnote.attribute('id').value == id
          description = []
          paragraph_number = 0
          footnote.xpath('w:p').each do |paragraph|
            description << DocxParagraph.parse(paragraph, paragraph_number, default_paragraph, default_character)
            paragraph_number += 1
          end
          return description
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ooxml_parser-0.1.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb
ooxml_parser-0.1.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb