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.

Constant Summary collapse

INVALID_ARGUMENTS =

Error message for invalid options

'part_name and content_type are required'

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.



11
12
13
14
15
16
# File 'lib/axlsx/content_type/override.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)


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

def content_type
  @content_type
end

#part_nameString Also known as: PartName

The name and location of the part.

Returns:

  • (String)


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

def part_name
  @part_name
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/override.rb', line 43

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