class OoxmlParser::ContentTypes
Class for data from `[Content_Types].xml` file
Attributes
content_types_list[RW]
@return [Array] list of content types
Public Class Methods
new(parent: nil)
click to toggle source
Calls superclass method
# File lib/ooxml_parser/common_parser/common_data/content_types.rb, line 11 def initialize(parent: nil) @content_types_list = [] super end
Public Instance Methods
[](key)
click to toggle source
@return [Array] accessor
# File lib/ooxml_parser/common_parser/common_data/content_types.rb, line 17 def [](key) @content_types_list[key] end
by_type(type)
click to toggle source
Get content definition by type @param [String] type of definition @return [Object] resulting objects
# File lib/ooxml_parser/common_parser/common_data/content_types.rb, line 41 def by_type(type) @content_types_list.select { |item| item.content_type == type } end
parse()
click to toggle source
Parse ContentTypes
object @return [ContentTypes] result of parsing
# File lib/ooxml_parser/common_parser/common_data/content_types.rb, line 23 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