Class: Axlsx::Override

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

Overview

An override 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 = {}) ⇒ Override

Creates a new Override object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • PartName (String)
  • ContentType (String)

Raises:

  • (ArgumentError)

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



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

def initialize(options={})
  raise ArgumentError, "PartName and ContentType are required" unless options[:PartName] && 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)


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

def ContentType
  @ContentType
end

#PartNameString

The name and location of the part.

Returns:

  • (String)


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

def PartName
  @PartName
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


35
36
37
38
39
# File 'lib/axlsx/content_type/override.rb', line 35

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