Class: Docxi::Word::Contents::TableOfContent::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/docxi/word/contents/table_of_content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, page = nil, options = {}) ⇒ Row

Returns a new instance of Row.



35
36
37
38
39
# File 'lib/docxi/word/contents/table_of_content.rb', line 35

def initialize(text, page=nil, options={})
  @text = text
  @page = page
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



34
35
36
# File 'lib/docxi/word/contents/table_of_content.rb', line 34

def options
  @options
end

#pageObject

Returns the value of attribute page.



34
35
36
# File 'lib/docxi/word/contents/table_of_content.rb', line 34

def page
  @page
end

#textObject

Returns the value of attribute text.



34
35
36
# File 'lib/docxi/word/contents/table_of_content.rb', line 34

def text
  @text
end

Instance Method Details

#render(xml) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# 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