Class: OoxmlParser::DocumentProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocumentProperties
- Defined in:
- lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#words ⇒ Object
Returns the value of attribute words.
Class Method Summary collapse
-
.parse ⇒ DocumentProperties
Parse Document properties.
Instance Method Summary collapse
-
#initialize(pages = nil, words = nil) ⇒ DocumentProperties
constructor
A new instance of DocumentProperties.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file
Constructor Details
#initialize(pages = nil, words = nil) ⇒ DocumentProperties
Returns a new instance of DocumentProperties.
6 7 8 9 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb', line 6 def initialize(pages = nil, words = nil) @pages = pages @words = words end |
Instance Attribute Details
#pages ⇒ Object
Returns the value of attribute pages.
4 5 6 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb', line 4 def pages @pages end |
#words ⇒ Object
Returns the value of attribute words.
4 5 6 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb', line 4 def words @words end |
Class Method Details
.parse ⇒ DocumentProperties
Parse Document properties
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb', line 13 def self.parse properties = DocumentProperties.new 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 properties end doc_props = XmlSimple.xml_in(File.open(properties_file)) properties.pages = doc_props['Pages'].first.to_i unless doc_props['Pages'].nil? properties.words = doc_props['Words'].first.to_i unless doc_props['Words'].nil? properties end |