Changeset 1281
- Timestamp:
- 02/20/08 08:30:09 (9 months ago)
- Files:
-
- ruport/trunk/lib/ruport/formatter.rb (modified) (1 diff)
- ruport/trunk/lib/ruport/formatter/csv.rb (modified) (1 diff)
- ruport/trunk/lib/ruport/formatter/html.rb (modified) (2 diffs)
- ruport/trunk/lib/ruport/formatter/text.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ruport/trunk/lib/ruport/formatter.rb
r1262 r1281 65 65 # 66 66 module RenderingTools 67 # Iterates through <tt>data</tt> and passes68 # each row to render_row with the given options.69 def render_data_by_row(options={},&block)70 data.each do |r|71 render_row(r,options,&block)72 end73 end74 75 67 # Uses Renderer::Row to render the Row object with the 76 68 # given options. ruport/trunk/lib/ruport/formatter/csv.rb
r1260 r1281 79 79 80 80 # Produces CSV output for a data row. 81 def build_row 81 def build_row(data = self.data) 82 82 csv_writer << data 83 83 end ruport/trunk/lib/ruport/formatter/html.rb
r1277 r1281 52 52 # Replaces nil and empty strings with " " 53 53 def build_table_body 54 render_data_by_row do |rend| 55 r = rend.data 56 rend.data = r.map { |e| e.to_s.empty? ? " " : e } 54 data.each do |row| 55 build_row(row.map { |e| e.to_s.empty? ? " " : e }) 57 56 end 58 57 end … … 64 63 65 64 # Renders individual rows for the table. 66 def build_row 65 def build_row(data = self.data) 67 66 output << 68 67 "\t\t<tr>\n\t\t\t<td>" + ruport/trunk/lib/ruport/formatter/text.rb
r1251 r1281 95 95 calculate_max_col_widths unless options.max_col_width 96 96 97 render_data_by_row do |rend| 98 rend.options do |o| 99 o.max_col_width = options.max_col_width 100 o.alignment = options.alignment 101 o.table_width = options.table_width 102 o.ignore_table_width = options.ignore_table_width 103 end 104 end 97 data.each { |row| build_row(row) } 105 98 106 99 output << fit_to_width(hr) … … 115 108 # Uses fit_to_width to truncate the row if necessary. 116 109 # 117 def build_row 110 def build_row(data = self.data) 118 111 max_col_widths_for_row(data) unless options.max_col_width 119 112
