Sha256: 83719681bdeb2505dd015636166f649d50d2461f84cc544b4ffac394bb2dc49d

Contents?: true

Size: 936 Bytes

Versions: 13

Compression:

Stored size: 936 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 = "#{root_object.unpacked_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

13 entries across 13 versions & 1 rubygems

Version Path
ooxml_parser-0.38.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.37.1 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.37.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.36.1 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.36.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.35.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.34.2 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.34.1 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.34.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.33.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.32.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.31.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
ooxml_parser-0.30.0 lib/ooxml_parser/docx_parser/document_structure/document_properties.rb