Class: Axlsx::AbstractContentType

Inherits:
Object
  • Object
show all
Includes:
OptionsParser
Defined in:
lib/axlsx/content_type/abstract_content_type.rb

Overview

This class extracts the common parts from Default and Override

Direct Known Subclasses

Default, Override

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ AbstractContentType

Initializes an abstract content type

See Also:

  • Override


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

def initialize(options = {})
  parse_options options
end

Instance Attribute Details

#content_typeString Also known as: ContentType

The type of content.

Returns:

  • (String)


16
17
18
# File 'lib/axlsx/content_type/abstract_content_type.rb', line 16

def content_type
  @content_type
end

Instance Method Details

#to_xml_string(node_name = '', str = +'')) ⇒ Object

Serialize the contenty type to xml



28
29
30
31
32
33
34
35
# File 'lib/axlsx/content_type/abstract_content_type.rb', line 28

def to_xml_string(node_name = '', str = +'')
  str << '<' << node_name << ' '
  Axlsx.instance_values_for(self).each_with_index do |key_value, index|
    str << ' ' unless index.zero?
    str << Axlsx.camel(key_value.first) << '="' << key_value.last.to_s << '"'
  end
  str << '/>'
end