Sha256: 57e0f14f9839587e9f61b5eef12463d0703dbc8c492b18b0ada381732f2b15b9

Contents?: true

Size: 943 Bytes

Versions: 4

Compression:

Stored size: 943 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

4 entries across 4 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/rels/relationships.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/rels/relationships.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/rels/relationships.rb
caxlsx-4.1.0 lib/axlsx/rels/relationships.rb