Sha256: da194f09dc05061650c4799ae2d2cad04703208ef85baec772dd4666fbcf98ab

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

# encoding: UTF-8
module Axlsx
  # An default content part. These parts are automatically created by for you based on the content of your package.
  class Default

    # The extension of the content type.
    # @return [String]
    attr_reader :extension
    alias :Extension :extension

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

    #Creates a new Default object
    # @option options [String] extension
    # @option options [String] content_type
    # @raise [ArgumentError] An argument error is raised if both extension and content_type are not specified.
    def initialize(options={})
      raise ArgumentError, "extension and content_type are required" unless (options[:Extension] || options[:extension]) && (options[:content_type] || options[:ContentType])
      options.each do |o|
        self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
      end
    end


    # Sets the file extension for this content type.
    def extension=(v) Axlsx::validate_string v; @extension = v end
    alias :Extension= :extension=

    # Sets 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=

    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = '')
      str << '<Default '
      str << instance_values.map { |key, value| '' << Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ')
      str << '/>'
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axlsx-1.1.7 lib/axlsx/content_type/default.rb
axlsx-1.1.6 lib/axlsx/content_type/default.rb