Class: Axlsx::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/content_type/default.rb

Overview

An default content part. These parts are automatically created by for you based on the content of your package.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Default

Creates a new Default object

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • Extension (String)
  • ContentType (String)

Raises:

  • (ArgumentError)

    An argument error is raised if both Extension and ContentType are not specified.



18
19
20
21
22
23
# File 'lib/axlsx/content_type/default.rb', line 18

def initialize(options={})
  raise ArgumentError, "Extension and ContentType are required" unless options[:Extension] && options[:ContentType]
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#ContentTypeString

The type of content.

Returns:

  • (String)


12
13
14
# File 'lib/axlsx/content_type/default.rb', line 12

def ContentType
  @ContentType
end

#ExtensionString

The extension of the content type.

Returns:

  • (String)


8
9
10
# File 'lib/axlsx/content_type/default.rb', line 8

def Extension
  @Extension
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


34
35
36
37
38
# File 'lib/axlsx/content_type/default.rb', line 34

def to_xml_string(str = '')
  str << '<Default '
  str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
  str << '/>'
end