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.



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

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

Returns ContentType The type of content. TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, DRAWING_CT are allowed.

Returns:

  • (String)

    ContentType The type of content. TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, DRAWING_CT are allowed



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

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)


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

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