summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/rels/relationship.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2011-11-20 23:22:04 +0900
committerRandy Morgan <[email protected]>2011-11-20 23:22:04 +0900
commite53f04284618713b0a90b7a691425c380e829476 (patch)
tree801fea138160f9af426d62bf94ad5bf97123ece9 /lib/axlsx/rels/relationship.rb
downloadcaxlsx-e53f04284618713b0a90b7a691425c380e829476.tar.gz
caxlsx-e53f04284618713b0a90b7a691425c380e829476.zip
first commit
Diffstat (limited to 'lib/axlsx/rels/relationship.rb')
-rw-r--r--lib/axlsx/rels/relationship.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/axlsx/rels/relationship.rb b/lib/axlsx/rels/relationship.rb
new file mode 100644
index 00000000..57b9afc0
--- /dev/null
+++ b/lib/axlsx/rels/relationship.rb
@@ -0,0 +1,43 @@
+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_accessor :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_accessor :Type
+ def initialize(type, target)
+ self.Target=target
+ self.Type=type
+ end
+
+ def Target=(v) Axlsx::validate_string v; @Target = v end
+ def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
+
+ # Serializes the relationship
+ # TODO: use object.rId to get this infomation
+ # @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