module OoxmlParser::OoxmlDocumentObjectHelper
Module for helper methods for OOXMLDocumentObject
Constants
- VALUE_TO_SYMBOL_HASH
-
@return [Hash] Hash to Convert value to human readable symbol
Public Instance Methods
Source
# File lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb, line 77 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}"] = 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
Convert object to hash @return [Hash]
Private Instance Methods
Source
# File lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb, line 112 def root_object tree_object = self tree_object = tree_object.parent until tree_object.parent.nil? tree_object end
Source
# File lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb, line 105 def value_to_symbol(value) symbol = VALUE_TO_SYMBOL_HASH[value.value.to_sym] return value.value.to_sym if symbol.nil? symbol end
Convert value to human readable symbol @param [String] value to convert @return [Symbol]