class RT::RT2HTMLVisitor
Constants
- INCLUDE_SUFFIX
- OUTPUT_SUFFIX
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/rt/rt2html-lib.rb, line 13 def initialize() super end
Public Instance Methods
setup()
click to toggle source
# File lib/rt/rt2html-lib.rb, line 25 def setup block('setup') do s = %Q[<table border="1">\n] s << %Q[<caption>#{esc(caption)}</caption>\n] if caption s end end
teardown()
click to toggle source
# File lib/rt/rt2html-lib.rb, line 33 def teardown block('teardown') do %Q[</table>\n] end end
visit_Body(ary = @body)
click to toggle source
# File lib/rt/rt2html-lib.rb, line 74 def visit_Body(ary = @body) block('Body') do ret = "<tbody>\n" ary.each do |line| ret << '<tr>' each_cell(line) do |cell| ret << cell_element(cell, %Q[td align="#{cell.align.id2name}"]) ret << esc(cell.value) ret << '</td>' end ret << "</tr>\n" end ret << "</tbody>\n" end end
visit_Header(ary = @header)
click to toggle source
# File lib/rt/rt2html-lib.rb, line 54 def visit_Header(ary = @header) block('Header') do if ary.empty? "" else ret = "<thead>\n" ary.each do |line| ret << '<tr>' each_cell(line) do |cell| ret << cell_element(cell, 'th') ret << esc(cell.value) ret << '</th>' end ret << "</tr>\n" end ret << "</thead>\n" end end end
Private Instance Methods
block(name) { |+ %Q| ... }
click to toggle source
# File lib/rt/rt2html-lib.rb, line 15 def block(name) %Q[<!-- #{name} -->\n] + yield + %Q[<!-- #{name} end -->\n\n] end
cell_element(cell, name)
click to toggle source
# File lib/rt/rt2html-lib.rb, line 39 def cell_element(cell, name) rs, cs = cell.rowspan, cell.colspan if rs == 1 and cs == 1 ret = "<#{name}>" elsif rs == 1 ret = %Q[<#{name} colspan="#{cs}">] elsif cs == 1 ret = %Q[<#{name} rowspan="#{rs}">] else ret = %Q[<#{name} colspan="#{cs}" rowspan="#{rs}">] end ret end
esc(str)
click to toggle source
# File lib/rt/rt2html-lib.rb, line 22 def esc(str) CGI.escapeHTML(str) end