Class: OoxmlParser::DocumentProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocumentProperties
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/document_properties.rb
Overview
Document Properties
Instance Attribute Summary collapse
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#words ⇒ Object
Returns the value of attribute words.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#parse ⇒ DocumentProperties
Parse Document properties.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
This class inherits a constructor from OoxmlParser::OOXMLDocumentObject
Instance Attribute Details
#pages ⇒ Object
Returns the value of attribute pages.
6 7 8 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_properties.rb', line 6 def pages @pages end |
#words ⇒ Object
Returns the value of attribute words.
6 7 8 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_properties.rb', line 6 def words @words end |
Instance Method Details
#parse ⇒ DocumentProperties
Parse Document properties
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_properties.rb', line 10 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 |