Class: Axlsx::Relationships

Inherits:
SimpleTypedList 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 Attribute Summary

Attributes inherited from SimpleTypedList

allowed_types, locked_at, serialize_as

Instance Method Summary (collapse)

Methods inherited from SimpleTypedList

#<<, #==, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

Constructor Details

- (Relationships) initialize

Creates a new Relationships collection based on SimpleTypedList



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

def initialize
  super Relationship
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Axlsx::SimpleTypedList

Instance Method Details

- (String) to_xml

Serializes the relationships document.

Returns:

  • (String)


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

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
end