Class: Axlsx::Relationship
- Inherits:
-
Object
- Object
- Axlsx::Relationship
- Defined in:
- lib/axlsx/rels/relationship.rb
Overview
Packages automatically manage relationships.
A relationship defines a reference between package parts.
Instance Attribute Summary collapse
-
#Target ⇒ String
The location of the relationship target.
-
#TargetMode ⇒ Object
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.
-
#Type ⇒ String
The type of relationship.
Instance Method Summary collapse
-
#initialize(type, target, options = {}) ⇒ Relationship
constructor
creates a new relationship.
-
#to_xml_string(rId, str = '') ⇒ String
serialize relationship.
Constructor Details
#initialize(type, target, options = {}) ⇒ Relationship
creates a new relationship
36 37 38 39 40 |
# File 'lib/axlsx/rels/relationship.rb', line 36 def initialize(type, target, ={}) self.Target=target self.Type=type self.TargetMode = .delete(:target_mode) if [:target_mode] end |
Instance Attribute Details
#Target ⇒ String
The location of the relationship target
9 10 11 |
# File 'lib/axlsx/rels/relationship.rb', line 9 def Target @Target end |
#TargetMode ⇒ Object
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.
30 31 32 |
# File 'lib/axlsx/rels/relationship.rb', line 30 def TargetMode @TargetMode end |
#Type ⇒ String
Supported types are defined as constants in Axlsx:
The type of relationship
24 25 26 |
# File 'lib/axlsx/rels/relationship.rb', line 24 def Type @Type end |
Instance Method Details
#to_xml_string(rId, str = '') ⇒ String
serialize relationship
54 55 56 57 58 59 60 |
# File 'lib/axlsx/rels/relationship.rb', line 54 def to_xml_string(rId, str = '') h = self.instance_values h[:Id] = 'rId' << rId.to_s str << '<Relationship ' str << h.map { |key, value| '' << key.to_s << '="' << value.to_s << '"'}.join(' ') str << '/>' end |