Sha256: 45d078360d9bb11555dde2a802c2b7e750e563cc34724bba61f129a75f9ae750

Contents?: true

Size: 943 Bytes

Versions: 36

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

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 = parse_xml(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

36 entries across 36 versions & 1 rubygems

Version Path
ooxml_parser-0.29.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.28.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.27.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.26.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.25.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.24.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.23.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.22.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.21.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.20.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.19.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.18.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.18.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.17.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.16.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.15.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.14.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.14.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
ooxml_parser-0.14.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb