Class: RTF::ListTable

Inherits:
Object
  • Object
show all
Defined in:
lib/rtf/list.rb

Instance Method Summary collapse

Constructor Details

#initializeListTable

Returns a new instance of ListTable.



3
4
5
# File 'lib/rtf/list.rb', line 3

def initialize
  @templates = []
end

Instance Method Details

#new_templateObject



7
8
9
10
# File 'lib/rtf/list.rb', line 7

def new_template
  @templates.push ListTemplate.new(next_template_id)
  @templates.last
end

#to_rtf(indent = 0) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rtf/list.rb', line 12

def to_rtf(indent=0)
  return '' if @templates.empty?

  prefix = indent > 0 ? ' ' * indent : ''

  # List table
  text = "#{prefix}{\\*\\listtable"
  @templates.each {|tpl| text << tpl.to_rtf}
  text << "}"

  # List override table, a Cargo Cult.
  text << "#{prefix}{\\*\\listoverridetable"
  @templates.each do |tpl|
    text << "{\\listoverride\\listid#{tpl.id}\\listoverridecount0\\ls#{tpl.id}}"
  end
  text << "}\n"
end