blob: 23e6428a7d418a43a6e4c216a8037207d816216c (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# encoding: UTF-8
module Axlsx
# A relationship defines a reference between package parts.
# @note Packages automatcially manage relationships.
class Relationship
# The location of the relationship target
# @return [String]
attr_reader :Target
# The type of relationship
# @note Supported types are defined as constants in Axlsx:
# @see XML_NS_R
# @see TABLE_R
# @see WORKBOOK_R
# @see WORKSHEET_R
# @see APP_R
# @see RELS_R
# @see CORE_R
# @see STYLES_R
# @see CHART_R
# @see DRAWING_R
# @return [String]
attr_reader :Type
# The target mode of the relationship
# used for hyperlink type relationships to mark the relationship to an external resource
# TargetMode can be specified during initialization by passing in a :target_mode option
# Target mode must be :external for now.
attr_reader :TargetMode
# creates a new relationship
# @param [String] Type The type of the relationship
# @param [String] Target The target for the relationship
# @option [Symbol] target_mode only accepts :external.
def initialize(type, target, options={})
self.Target=target
self.Type=type
self.TargetMode = options.delete(:target_mode) if options[:target_mode]
end
# @see Target
def Target=(v) Axlsx::validate_string v; @Target = v end
# @see Type
def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
# @see TargetMode
def TargetMode=(v) RestrictionValidator.validate 'Relationship.TargetMode', [:External, :Internal], v; @TargetMode = v; end
# Serializes the relationship
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
# @param [String] rId the reference id of the object.
# @return [String]
def to_xml(xml, rId)
h = self.instance_values
h[:Id] = rId
xml.Relationship(h)
end
end
end
|