Module: OoxmlParser::OoxmlDocumentObjectHelper
- Included in:
- OOXMLDocumentObject
- Defined in:
- lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb
Overview
Module for helper methods for OOXMLDocumentObject
Instance Method Summary collapse
-
#to_hash ⇒ Hash
Convert object to hash.
Instance Method Details
#to_hash ⇒ Hash
Convert object to hash
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb', line 8 def to_hash result_hash = {} instance_variables.each do |current_attribute| next if current_attribute == :@parent attribute_value = instance_variable_get(current_attribute) next unless attribute_value if attribute_value.is_a?(Array) attribute_value.each_with_index do |object_element, index| result_hash["#{current_attribute}_#{index}".to_sym] = object_element.to_hash end else result_hash[current_attribute.to_sym] = if attribute_value.respond_to?(:to_hash) attribute_value.to_hash else attribute_value.to_s end end end result_hash end |