class OoxmlParser::Note
Class with data of Note
Attributes
assigned_to[RW]
elements[RW]
type[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb, line 8 def initialize @elements = [] super(parent: nil) end
parse(params)
click to toggle source
Parse note data @param params [Hash] data to parse @return [Note] result of parsing
# File lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb, line 16 def self.parse(params) note = Note.new note.type = params[:type] note.assigned_to = params[:assigned_to] note.parent = params[:parent] doc = note.parse_xml(note.file_path(params[:target])) if note.type.include?('footer') xpath_note = '//w:ftr' elsif note.type.include?('header') xpath_note = '//w:hdr' end doc.search(xpath_note).each do |ftr| number = 0 ftr.xpath('*').each do |sub_element| case sub_element.name when 'p' note.elements << params[:default_paragraph].dup.parse(sub_element, number, params[:default_character], parent: note) number += 1 when 'tbl' note.elements << Table.new(parent: note).parse(sub_element, number) number += 1 end end end note end
Public Instance Methods
file_path(target)
click to toggle source
@param target [String] name of target @return [String] path to note xml file
# File lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb, line 45 def file_path(target) file = "#{OOXMLDocumentObject.path_to_folder}word/#{target}" return file if File.exist?(file) "#{OOXMLDocumentObject.path_to_folder}#{target}" unless File.exist?(file) end