class Docxi::Word::Contents::TableOfContent::Row

Attributes

options[RW]
page[RW]
text[RW]

Public Class Methods

new(text, page=nil, options={}) click to toggle source
# File lib/docxi/word/contents/table_of_content.rb, line 35
def initialize(text, page=nil, options={})
  @text = text
  @page = page
  @options = options
end

Public Instance Methods

render(xml) click to toggle source
# File lib/docxi/word/contents/table_of_content.rb, line 41
def render(xml)
  if @page.nil?
    xml['w'].p do
      xml['w'].pPr do
        xml['w'].spacing( 'w:before' => "0", 'w:after' => "160")
      end
      xml['w'].r do
        xml['w'].tab
        xml['w'].t @text
      end
    end
  else
    xml['w'].p do
      xml['w'].pPr do
        xml['w'].pStyle( 'w:val' => "ListParagraph") # TODO: Apply styles
        xml['w'].spacing( 'w:before' => "0", 'w:after' => "160")
        xml['w'].tabs do
          xml['w'].tab( 'w:val' => "right", 'w:leader' => @options[:leader] || 'dot', 'w:pos' => @options[:pos] || 9360 )
        end
      end
      xml['w'].r do
        xml['w'].t @text
      end
      xml['w'].r do
        xml['w'].tab
        xml['w'].t( @page, 'xml:space' => "preserve" )
      end
    end
  end
end