ReportBuilder::Builder::Html

Attributes

directory[R]

Public Class Methods

code() click to toggle source
    # File lib/reportbuilder/builder/html.rb, line 14
14:       def self.code
15:         %{html htm}
16:       end
new(builder, options) click to toggle source
    # File lib/reportbuilder/builder/html.rb, line 6
 6:       def initialize(builder, options)
 7:         super
 8:         @directory = @options.delete :directory
 9:         @body=""
10:         @headers=[]
11:         @footers=[]
12:       end

Public Instance Methods

basic_css() click to toggle source
    # File lib/reportbuilder/builder/html.rb, line 21
21:       def basic_css
22:                 <style>        body {          margin:0;          padding:1em;        }        table {          border-collapse: collapse;        }        table td {          border: 1px solid black;        }        .section {          margin:0.5em;        }        </style>
23:       end
css(css) click to toggle source
     # File lib/reportbuilder/builder/html.rb, line 96
 96:       def css(css)
 97:         if(File.exists? css)
 98:           if(!File.exists? @directory+"/css/"+File.basename(css))
 99:             FileUtils.mkdir @directory+"/css"
100:             FileUtils.cp css, @directory+"/css/"+File.basename(css)
101:           end
102:           @headers.push("<link rel='stylesheet' type='text/css' href='css/#{File.basename(css)}' />")
103:         end
104:       end
default_options() click to toggle source
    # File lib/reportbuilder/builder/html.rb, line 18
18:       def default_options
19:         {:directory => Dir.pwd}
20:       end
html(t) click to toggle source
     # File lib/reportbuilder/builder/html.rb, line 111
111:       def html(t)
112:         ws=(" "*parse_level*2)
113:         @body << ws << t << "\n"
114:       end
js(js) click to toggle source
    # File lib/reportbuilder/builder/html.rb, line 86
86:       def js(js)
87:         if(File.exists? js)
88:           if(!File.exists? @directory+"/js/"+File.basename(js))
89:             FileUtils.mkdir @directory+"/js"
90:             FileUtils.cp js,@directory+"/js/"+File.basename(js)
91:           end
92:           @headers.push("<script type='text/javascript' src='js/#{File.basename(js)}'></script>")
93:         end
94:       end
out() click to toggle source
    # File lib/reportbuilder/builder/html.rb, line 41
41:       def out
42:         out= <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" ><title>#{@builder.name}</title>#{basic_css}
43:         out << @headers.join("\n")
44:         out << "</head><body>\n"
45:         out << "<h1>#{@builder.name}</h1>"
46:         if(@toc.size>0)                      
47:         out << "<div id='toc'><div class='title'>List of contents</div>\n"
48:           actual_level=0
49:           
50:           @toc.each do |anchor,name,level|
51:             
52:             if actual_level!=level
53:               if actual_level > level
54:                 (actual_level-level).times { out << "</ul>\n"}
55:               else
56:                 (level-actual_level).times { out << "<ul>\n"}
57:               end
58:             end
59:             
60:             out << "<li><a href='##{anchor}'>#{name}</a></li>\n"
61:             actual_level=level
62:           end
63:           actual_level.times { out << "</ul>\n"}
64:           out << "</div>\n"
65:         end
66:         if (@list_tables.size>0)
67:           out << "<div class='tot'><div class='title'>List of tables</div><ul>"
68:           @list_tables.each {|anchor,name|
69:             out << "<li><a href='#"+anchor+"'>#{name}</a></li>"
70:           }
71:           out << "</ul></div>\n"
72:         end
73: 
74:         out << @body
75:         out << @footers.join("\n")
76:         out << "</body></html>"
77:         out
78:       end
preformatted(t) click to toggle source
     # File lib/reportbuilder/builder/html.rb, line 115
115:       def preformatted(t)
116:         ws=(" "*parse_level*2)
117:         @body << ws << "<pre>#{t}</pre>\n"
118: 
119:       end
text(t) click to toggle source
     # File lib/reportbuilder/builder/html.rb, line 107
107:       def text(t)
108:         ws=(" "*parse_level*2)
109:         @body << ws << "<p>#{t}</p>\n"
110:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.