Sha256: 0c804abf32d5a6ec2ce78d6f5c5671b84bdc4dba912d4c7f50f9358c07467bc4

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

# frozen_string_literal: true

module Axlsx
  require 'axlsx/rels/relationship'

  # Relationships are a collection of Relations that define how package parts are related.
  # @note The package automatically manages releationships.
  class Relationships < SimpleTypedList
    # Creates a new Relationships collection based on SimpleTypedList
    def initialize
      super Relationship
    end

    # The relationship instance for the given source object, or nil if none exists.
    # @see Relationship#source_obj
    # @return [Relationship]
    def for(source_obj)
      find { |rel| rel.source_obj == source_obj }
    end

    # serialize relationships
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << '<Relationships xmlns="' << RELS_R << '">'
      each { |rel| rel.to_xml_string(str) }
      str << '</Relationships>'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caxlsx-4.0.0 lib/axlsx/rels/relationships.rb