Class: DiffRenderHtml
Instance Method Summary
collapse
#apply_row, #begin_diff, #end_diff, #quote
Methods inherited from DiffOutput
#apply_row, #begin_diff, #end_diff, #want_context
Constructor Details
Returns a new instance of DiffRenderHtml.
4
5
6
|
# File 'lib/coopy/diff_render_html.rb', line 4
def initialize
@text_to_insert = []
end
|
Instance Method Details
#begin_row(mode) ⇒ Object
16
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
|
# File 'lib/coopy/diff_render_html.rb', line 16
def begin_row(mode)
@td_open = '<td';
@td_close = '</td>';
@row_color = "";
@open = false;
case mode
when "@@"
@td_open = "<th"
@td_close = "</th>"
when "!"
@row_color = "#aaaaaa"
when "+++"
@row_color = "#7fff7f";
when "---"
@row_color = "#ff7f7f";
else
@open = true
end
tr = "<tr>";
row_decorate = ""
if @row_color!=""
row_decorate = " bgcolor=\"" + @row_color + "\" style=\"background-color: " + @row_color + ";\""
tr = "<tr" + row_decorate + ">"
end
self.insert(tr)
end
|
#begin_table ⇒ Object
12
13
14
|
# File 'lib/coopy/diff_render_html.rb', line 12
def begin_table
self.insert "<table class='csv_sheet'>\n"
end
|
#end_row ⇒ Object
58
59
60
|
# File 'lib/coopy/diff_render_html.rb', line 58
def end_row
self.insert "</tr>\n"
end
|
#end_table ⇒ Object
62
63
64
|
# File 'lib/coopy/diff_render_html.rb', line 62
def end_table
self.insert "</table>\n"
end
|
#html ⇒ Object
66
67
68
|
# File 'lib/coopy/diff_render_html.rb', line 66
def html
@text_to_insert.join ''
end
|
#insert(str) ⇒ Object
8
9
10
|
# File 'lib/coopy/diff_render_html.rb', line 8
def insert(str)
@text_to_insert << str
end
|
#insert_cell(txt, mode, separator) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/coopy/diff_render_html.rb', line 43
def insert_cell(txt,mode,separator)
cell_decorate = ""
case mode
when "+++"
cell_decorate = " bgcolor=\"#7fff7f\" style=\"background-color: #7fff7f;\""
when "---"
cell_decorate = " bgcolor=\"#ff7f7f\" style=\"background-color: #ff7f7f;\""
when "->"
cell_decorate = " bgcolor=\"#7f7fff\" style=\"background-color: #7f7fff;\""
end
self.insert @td_open+cell_decorate+">"
self.insert txt
self.insert @td_close
end
|
#to_string ⇒ Object
70
71
72
|
# File 'lib/coopy/diff_render_html.rb', line 70
def to_string
html
end
|