Class: TableData::Presenters::HTML
Instance Attribute Summary
#table
Instance Method Summary
collapse
#initialize, present
Instance Method Details
21
22
23
24
25
26
27
28
29
|
# File 'lib/tabledata/presenters/html.rb', line 21
def
<<-EOHTML
</tbody>
</table>
</body>
</html>
EOHTML
end
|
#html_head ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/tabledata/presenters/html.rb', line 9
def html_head
<<-EOHTML
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<table>
EOHTML
end
|
31
32
33
34
35
36
37
38
39
|
# File 'lib/tabledata/presenters/html.rb', line 31
def
if @table.
" <thead>\n <tr>\n"+
@table..map { |cell|" <th>#{CGI.escapeHTML(cell)}</th>" }.join("\n")+
"\n </tr>\n </thead>\n"
else
''
end
end
|
#string(options = nil) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/tabledata/presenters/html.rb', line 41
def string(options=nil)
html_head+
+
" </body>\n"+
@table.body.map { |row|
" <tr>\n"+row.map { |cell| " <td>#{CGI.escapeHTML(cell)}</td>" }.join("\n")+"\n </tr>"
}.join("\n")+
end
|
#write(path, options = nil) ⇒ Object
51
52
53
|
# File 'lib/tabledata/presenters/html.rb', line 51
def write(path, options=nil)
File.write(path, string, encoding: 'utf-8')
end
|