class Docxtor::ReferenceBuilder

Attributes

elements[RW]

Public Class Methods

new(elements) click to toggle source
# File lib/docxtor/reference_builder.rb, line 5
def initialize elements
  @elements = elements
  @elements.each_with_index { |el, i| el.reference_id = "rId#{i+1}" }
end

Public Instance Methods

content() click to toggle source
# File lib/docxtor/reference_builder.rb, line 14
def content
  xml = ::Builder::XmlMarkup.new

  xml.instruct! :xml, :version => "1.0", :encoding=>"UTF-8", :standalone => "yes"
  xml.Relationships "xmlns" => "http://schemas.openxmlformats.org/package/2006/relationships" do |xml|
    elements.each do |element|
      xml.Relationship "Id" => element.reference_id,
                       "Target" => element.name,
                       "Type" => element.reference_type
    end
  end

  xml.target!
end
filename() click to toggle source
# File lib/docxtor/reference_builder.rb, line 10
def filename
  "word/_rels/document.xml.rels"
end