Class: Axlsx::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/rels/relationship.rb

Overview

Note:

Packages automatcially manage relationships.

A relationship defines a reference between package parts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, target) ⇒ Relationship

Returns a new instance of Relationship.



24
25
26
27
# File 'lib/axlsx/rels/relationship.rb', line 24

def initialize(type, target)
  self.Target=target
  self.Type=type
end

Instance Attribute Details

#TargetString

The location of the relationship target

Returns:

  • (String)


8
9
10
# File 'lib/axlsx/rels/relationship.rb', line 8

def Target
  @Target
end

#TypeString

Note:

Supported types are defined as constants in Axlsx:

The type of relationship



23
24
25
# File 'lib/axlsx/rels/relationship.rb', line 23

def Type
  @Type
end

Instance Method Details

#to_xml(xml, rId) ⇒ String

Serializes the relationship TODO: use object.rId to get this infomation

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

  • rId (String)

    the reference id of the object.

Returns:

  • (String)


37
38
39
40
41
# File 'lib/axlsx/rels/relationship.rb', line 37

def to_xml(xml, rId)
  h = self.instance_values
  h[:Id] = rId
  xml.Relationship(h)
end