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.



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

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)


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

def ContentType
  @ContentType
end

#ExtensionString

The extension of the content type.

Returns:

  • (String)


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

def Extension
  @Extension
end

Instance Method Details

#to_xml(xml) ⇒ String

Serializes the object to xml

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

Returns:

  • (String)


33
34
35
# File 'lib/axlsx/content_type/default.rb', line 33

def to_xml(xml)
  xml.Default(self.instance_values)
end