Sha256: c2e3b2789b1d81b0174096ee50960885da2f0bd26bd85dee6d4ec3bce51f208a

Contents?: true

Size: 927 Bytes

Versions: 4

Compression:

Stored size: 927 Bytes

Contents

module OoxmlParser
  # Document Properties
  class DocumentProperties < OOXMLDocumentObject
    attr_accessor :pages, :words

    # Parse Document properties
    # @return [DocumentProperties]
    def parse
      properties_file = "#{OOXMLDocumentObject.path_to_folder}docProps/app.xml"
      unless File.exist?(properties_file)
        warn "There is no 'docProps/app.xml' in docx. It may be some problem with it"
        return self
      end
      node = Nokogiri::XML(File.open(properties_file))
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'Properties'
          node_child.xpath('*').each do |node_child_child|
            case node_child_child.name
            when 'Pages'
              @pages = node_child_child.text.to_i
            when 'Words'
              @words = node_child_child.text.to_i
            end
          end
        end
      end
      self
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.4.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.3.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.2.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb