Class: Axlsx::Relationships

Inherits:
SimpleTypedList
  • Object
show all
Defined in:
lib/axlsx/rels/relationships.rb

Overview

Note:

The package automatically manages releationships.

Relationships are a collection of Relations that define how package parts are related.

Instance Method Summary collapse

Constructor Details

#initializeRelationships

Creates a new Relationships collection based on SimpleTypedList



10
11
12
# File 'lib/axlsx/rels/relationships.rb', line 10

def initialize
  super Relationship
end

Instance Method Details

#to_xmlString

Serializes the relationships document.

Returns:

  • (String)


22
23
24
25
26
27
28
29
# File 'lib/axlsx/rels/relationships.rb', line 22

def to_xml()
  builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
    xml.Relationships(:xmlns => Axlsx::RELS_R) {
      each_with_index { |rel, index| rel.to_xml(xml, "rId#{index+1}") }
    }
  end
  builder.to_xml(:save_with => 0)
end

#to_xml_string(str = '') ⇒ Object



14
15
16
17
18
19
# File 'lib/axlsx/rels/relationships.rb', line 14

def to_xml_string(str = '')
  str << '<?xml version="1.0" encoding="UTF-8"?>'
  str << '<Relationships xmlns="' << RELS_R << '">'
  each_with_index { |rel, index| rel.to_xml_string(index+1, str) }
  str << '</Relationships>'
end