Sha256: d1308e14f3e0a1d876f16bcbc42c1ed8d8c5d5850d6115e8fd70e44aa6cf944a

Contents?: true

Size: 998 Bytes

Versions: 4

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

module Axlsx
  # This class extracts the common parts from Default and Override
  class AbstractContentType
    include Axlsx::OptionsParser

    # Initializes an abstract content type
    # @see Default, Override
    def initialize(options = {})
      parse_options options
    end

    # The type of content.
    # @return [String]
    attr_reader :content_type
    alias :ContentType :content_type

    # The content type.
    # @see Axlsx#validate_content_type
    def content_type=(v)
      Axlsx.validate_content_type v
      @content_type = v
    end
    alias :ContentType= :content_type=

    # Serialize the contenty type to xml
    def to_xml_string(node_name = '', str = +'')
      str << '<' << node_name << ' '
      Axlsx.instance_values_for(self).each_with_index do |key_value, index|
        str << ' ' unless index.zero?
        str << Axlsx.camel(key_value.first) << '="' << key_value.last.to_s << '"'
      end
      str << '/>'
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/content_type/abstract_content_type.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/content_type/abstract_content_type.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/content_type/abstract_content_type.rb
caxlsx-4.1.0 lib/axlsx/content_type/abstract_content_type.rb