Sha256: 9dc3efd6417fa341022266ba8fa93aadb66dd046f51dd6f724d85e77fa3d31be
Contents?: true
Size: 1.28 KB
Versions: 25
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require_relative 'content_types/content_type_default' require_relative 'content_types/content_type_override' module OoxmlParser # Class for data from `[Content_Types].xml` file class ContentTypes < OOXMLDocumentObject # @return [Array] list of content types attr_accessor :content_types_list def initialize(parent: nil) @content_types_list = [] super end # @return [Array] accessor def [](key) @content_types_list[key] end # Parse ContentTypes object # @return [ContentTypes] result of parsing def parse doc = Nokogiri::XML.parse(File.open("#{OOXMLDocumentObject.path_to_folder}/[Content_Types].xml")) node = doc.xpath('*').first node.xpath('*').each do |node_child| case node_child.name when 'Default' @content_types_list << ContentTypeDefault.new(parent: self).parse(node_child) when 'Override' @content_types_list << ContentTypeOverride.new(parent: self).parse(node_child) end end self end # Get content definition by type # @param [String] type of definition # @return [Object] resulting objects def by_type(type) @content_types_list.select { |item| item.content_type == type } end end end
Version data entries
25 entries across 25 versions & 1 rubygems