Class: Caracal::Renderers::FooterRenderer

Inherits:
XmlRenderer
  • Object
show all
Defined in:
lib/caracal/renderers/footer_renderer.rb

Instance Attribute Summary

Attributes inherited from XmlRenderer

#document

Instance Method Summary collapse

Methods inherited from XmlRenderer

#initialize, render

Constructor Details

This class inherits a constructor from Caracal::Renderers::XmlRenderer

Instance Method Details

#to_xmlObject

This method produces the xml required for the ‘word/settings.xml` sub-document.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/caracal/renderers/footer_renderer.rb', line 17

def to_xml
  builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
    xml['w'].ftr root_options do
      xml['w'].p paragraph_options do
        xml['w'].pPr do
          xml['w'].contextualSpacing({ 'w:val' => '0' })
          xml['w'].jc({ 'w:val' => "#{ document.page_number_align }" })
        end
        unless document.page_number_label.nil?
          xml['w'].r run_options do
            xml['w'].rPr do
              xml['w'].rStyle({ 'w:val' => 'PageNumber' })
            end
            xml['w'].t({ 'xml:space' => 'preserve' }) do
              xml.text "#{ document.page_number_label } "
            end
          end
        end
        xml['w'].fldSimple({ 'w:dirty' => '0', 'w:instr' => 'PAGE', 'w:fldLock' => '0' }) do
          xml['w'].r run_options do
            xml['w'].rPr
          end
        end
        xml['w'].r run_options do
          xml['w'].rPr do
            xml['w'].rtl({ 'w:val' => '0' })
          end
        end
      end
    end
  end
  builder.to_xml(save_options)
end