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.

Constant Summary collapse

INVALID_ARGUMENTS =

Error string for option validation

"extension and content_type are required"

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)
  • content_type (String)

Raises:

  • (ArgumentError)

    An argument error is raised if both extension and content_type are not specified.



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

def initialize(options={})
  raise ArgumentError, INVALID_ARGUMENTS unless validate_options(options)
  options.each do |name, value|
    self.send("#{name}=", value) if self.respond_to? "#{name}="
  end
end

Instance Attribute Details

#content_typeString Also known as: ContentType

The type of content.

Returns:

  • (String)


28
29
30
# File 'lib/axlsx/content_type/default.rb', line 28

def content_type
  @content_type
end

#extensionString Also known as: Extension

The extension of the content type.

Returns:

  • (String)


23
24
25
# File 'lib/axlsx/content_type/default.rb', line 23

def extension
  @extension
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


43
44
45
46
47
# File 'lib/axlsx/content_type/default.rb', line 43

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