Class: Rubyword::Writer::Part::Rels

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyword/writer/part/rels.rb

Instance Attribute Summary

Attributes inherited from Base

#rubyword, #section

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Rubyword::Writer::Part::Base

Instance Method Details

#writeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubyword/writer/part/rels.rb', line 6

def write
	xmlRels = {
		'docProps/core.xml'       => 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
		'docProps/app.xml'    => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
		'docProps/custom.xml'     => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
		'word/document.xml' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'
	}
	builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
		xml.Relationships(xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships') do
			3.times.each do |num|
				num = num + 1
				xml.Relationship(Id: "rId#{num}", Type: xmlRels.values[num], Target: xmlRels.keys[num])
			end
		end
	end
	builder.to_xml
end