class Docxer::Word::Footers::Footer

Attributes

content[RW]
id[RW]
options[RW]
relationships[RW]
sequence[RW]

Public Class Methods

new(options={}) { |self| ... } click to toggle source
# File lib/docxer/word/footers/footer.rb, line 9
def initialize(options={})
  @options = options
  @content = []
  @relationships = []

  if block_given?
    yield self
  else

  end
end

Public Instance Methods

content_type() click to toggle source
# File lib/docxer/word/footers/footer.rb, line 21
def content_type
  "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
end
page_numbers() click to toggle source
# File lib/docxer/word/footers/footer.rb, line 48
def page_numbers
  numbers = PageNumbers.new
  @content << numbers
  numbers
end
render(zip) click to toggle source
# File lib/docxer/word/footers/footer.rb, line 29
def render(zip)
  zip.put_next_entry("word/#{target}")
  zip.write(Docxer.to_xml(document))

  if !@relationships.empty?
    zip.put_next_entry("word/_rels/#{target}.rels")
    zip.write(Docxer.to_xml(relationships))
  end
end
target() click to toggle source
# File lib/docxer/word/footers/footer.rb, line 25
def target
  "footer#{id}.xml"
end
text(text, options={}) click to toggle source
# File lib/docxer/word/footers/footer.rb, line 39
def text(text, options={})
  options = @options.merge(options)
  element = Docxer::Word::Contents::Paragraph.new(options) do |p|
    p.text(text)
  end
  @content << element
  element
end

Private Instance Methods

document() click to toggle source
# File lib/docxer/word/footers/footer.rb, line 94
def document
  Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
    xml.ftr( 'xmlns:wpc' => "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", 'xmlns:mc' => "http://schemas.openxmlformats.org/markup-compatibility/2006", 'xmlns:o' => "urn:schemas-microsoft-com:office:office", 'xmlns:r' => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", 'xmlns:m' => "http://schemas.openxmlformats.org/officeDocument/2006/math", 'xmlns:v' => "urn:schemas-microsoft-com:vml", 'xmlns:wp14' => "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", 'xmlns:wp' => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", 'xmlns:w10' => "urn:schemas-microsoft-com:office:word", 'xmlns:w' => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", 'xmlns:w14' => "http://schemas.microsoft.com/office/word/2010/wordml", 'xmlns:wpg' => "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", 'xmlns:wpi' => "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", 'xmlns:wne' => "http://schemas.microsoft.com/office/word/2006/wordml", 'xmlns:wps' => "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", 'mc:Ignorable' => "w14 wp14" ) do
      xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "w" }
      @content.each do |element|
        element.render(xml)
      end
    end
  end
end