Sha256: bc9bccbe32255540e977dee6c520d2b134633546d8f5b6a5eb5dba2435b83d4c
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'goldendocx/content_types/default' require 'goldendocx/content_types/override' module Goldendocx module Parts class ContentTypes include Goldendocx::Document XML_PATH = '[Content_Types].xml' NAMESPACE = 'http://schemas.openxmlformats.org/package/2006/content-types' REQUIRED_DEFAULTS = { rels: 'application/vnd.openxmlformats-package.relationships+xml', xml: 'application/xml' }.with_indifferent_access.freeze tag :Types attribute :xmlns, default: NAMESPACE, readonly: true embeds_many :defaults, class_name: 'Goldendocx::ContentTypes::Default', uniqueness: true embeds_many :overrides, class_name: 'Goldendocx::ContentTypes::Override', uniqueness: true def initialize REQUIRED_DEFAULTS.map do |extension, content_type| build_defaults(extension: extension, content_type: content_type) end end def write_to(zos) zos.put_next_entry XML_PATH zos.write to_document_xml end def add_default(extension, content_type) return if defaults.any? { |default| extension == default.extension && content_type == default.content_type } build_defaults(extension: extension, content_type: content_type) end def add_override(part_name, content_type) return if overrides.any? { |override| part_name == override.part_name && content_type == override.content_type } build_override(part_name: part_name, content_type: content_type) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
goldendocx-0.2.3 | lib/goldendocx/parts/content_types.rb |