Sha256: b023a357539cb92a6187333de6cf618fc3e10d06d981efd87c1c87c23d479827

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
axlsx-1.0.7 lib/axlsx/rels/relationship.rb
axlsx-1.0.6 lib/axlsx/rels/relationship.rb
axlsx-1.0.5 lib/axlsx/rels/relationship.rb
axlsx-1.0.4 lib/axlsx/rels/relationship.rb
axlsx-1.0.3 lib/axlsx/rels/relationship.rb
axlsx-1.0.1 lib/axlsx/rels/relationship.rb
axlsx-1.0.0 lib/axlsx/rels/relationship.rb