class Docxi::Word::Relationships

Attributes

relationships[RW]

Public Class Methods

new() click to toggle source
# File lib/docxi/word/relationships.rb, line 10
def initialize
  @relationships = []
  @counter = 0
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", "styles.xml")
  add("http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects", "stylesWithEffects.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", "settings.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings", "webSettings.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", "fontTable.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", "theme/theme1.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", "endnotes.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", "footnotes.xml")
  add("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", "numbering.xml")
end

Public Instance Methods

add(type, target, tm = '') click to toggle source
# File lib/docxi/word/relationships.rb, line 24
def add(type, target, tm = '')
  relationship = create_relationship(sequence, type, target,tm)
  @relationships << relationship if relationship
  relationship
end
render(zip) click to toggle source
# File lib/docxi/word/relationships.rb, line 30
def render(zip)
  zip.put_next_entry('word/_rels/document.xml.rels')
  zip.write(Docxi.to_xml(document))
end

Private Instance Methods

create_relationship(id, type, target, tm = '') click to toggle source
# File lib/docxi/word/relationships.rb, line 46
def create_relationship(id, type, target, tm = '')
  Relationship.new(id, type, target, tm)
end
document() click to toggle source
# File lib/docxi/word/relationships.rb, line 36
def document
  Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
    xml.Relationships(xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships') do
      @relationships.each do |relationship|
        relationship.build(xml)
      end
    end
  end
end
sequence() click to toggle source
# File lib/docxi/word/relationships.rb, line 50
def sequence
  @counter += 1
  @@prefix + @counter.to_s
end