blob: 8f3b62ccbec1cd44d9393cc0e2fbbef680090499 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
module Axlsx
require 'axlsx/rels/relationship.rb'
# Relationships are a collection of Relations that define how package parts are related.
# @note The package automatically manages releationships.
class Relationships < SimpleTypedList
# Creates a new Relationships collection based on SimpleTypedList
def initialize
super Relationship
end
# The relationship instance for the given source object, or nil if none exists.
# @see Relationship#source_obj
# @return [Relationship]
def for(source_obj)
find{ |rel| rel.source_obj == source_obj }
end
# serialize relationships
# @param [String] str
# @return [String]
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
end
end
|