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

#for(source_obj) ⇒ Relationship

The relationship instance for the given source object, or nil if none exists.



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

def for(source_obj)
  @list.find{ |rel| rel.source_obj == source_obj }
end

#to_xml_string(str = '') ⇒ Object



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

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