Sha256: 70fae07521e274d87888b60691f29a4568335be1eedcc563330fe262689f772d

Contents?: true

Size: 1003 Bytes

Versions: 5

Compression:

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

    def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << '<Relationships xmlns="' << RELS_R << '">'
      each_with_index { |rel, index| rel.to_xml_string(index+1, str) }
      str << '</Relationships>'
    end
    # Serializes the relationships document.
    # @return [String]
    def to_xml()
      builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
        xml.Relationships(:xmlns => Axlsx::RELS_R) {
          each_with_index { |rel, index| rel.to_xml(xml, "rId#{index+1}") }
        }
      end
      builder.to_xml(:save_with => 0)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
axlsx-1.1.4 lib/axlsx/rels/relationships.rb
axlsx-1.1.3 lib/axlsx/rels/relationships.rb
axlsx-1.1.2 lib/axlsx/rels/relationships.rb
axlsx-1.1.1 lib/axlsx/rels/relationships.rb
axlsx-1.1.0 lib/axlsx/rels/relationships.rb