Class: OoxmlParser::ContentTypes
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::ContentTypes
- Defined in:
- lib/ooxml_parser/common_parser/common_data/content_types.rb
Overview
Class for data from ‘[Content_Types].xml` file
Instance Attribute Summary collapse
-
#content_types_list ⇒ Array
List of content types.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#[](key) ⇒ Array
Accessor.
-
#by_type(type) ⇒ Object
Get content definition by type.
-
#initialize(parent: nil) ⇒ ContentTypes
constructor
A new instance of ContentTypes.
-
#parse ⇒ ContentTypes
Parse ContentTypes object.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ ContentTypes
Returns a new instance of ContentTypes.
11 12 13 14 |
# File 'lib/ooxml_parser/common_parser/common_data/content_types.rb', line 11 def initialize(parent: nil) @content_types_list = [] super end |
Instance Attribute Details
#content_types_list ⇒ Array
Returns list of content types.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/content_types.rb', line 9 def content_types_list @content_types_list end |
Instance Method Details
#[](key) ⇒ Array
Returns accessor.
17 18 19 |
# File 'lib/ooxml_parser/common_parser/common_data/content_types.rb', line 17 def [](key) @content_types_list[key] end |
#by_type(type) ⇒ Object
Get content definition by type
41 42 43 |
# 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 ⇒ ContentTypes
Parse ContentTypes object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ooxml_parser/common_parser/common_data/content_types.rb', line 23 def parse doc = parse_xml("#{root_object.unpacked_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 |