Sha256: fceb2e202193b6075a8acdefbd67b7a28b3660a730c3657234e1ae173815b87b

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

# encoding: UTF-8
module Axlsx
require 'axlsx/rels/relationship.rb'

  # 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)
      @list.find{ |rel| rel.source_obj == source_obj }
    end
    
    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

3 entries across 3 versions & 2 rubygems

Version Path
caxlsx-2.0.2 lib/axlsx/rels/relationships.rb
axlsx-2.0.1 lib/axlsx/rels/relationships.rb
axlsx-2.0.0 lib/axlsx/rels/relationships.rb