Changeset 1275
- Timestamp:
- 02/10/08 09:16:40 (9 months ago)
- Files:
-
- ruport/branches/brian/exp-stage-data-2/lib/ruport/formatter.rb (modified) (1 diff)
- ruport/branches/brian/exp-stage-data-2/lib/ruport/formatter/csv.rb (modified) (1 diff)
- ruport/branches/brian/exp-stage-data-2/lib/ruport/formatter/html.rb (modified) (2 diffs)
- ruport/branches/brian/exp-stage-data-2/lib/ruport/formatter/text.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ruport/branches/brian/exp-stage-data-2/lib/ruport/formatter.rb
r1262 r1275 67 67 # Iterates through <tt>data</tt> and passes 68 68 # each row to render_row with the given options. 69 # This interface is is very inefficient, since new Renderer and 70 # Formatter objects are created for every row, and is deprecated. 71 # Iterate the rows directly within your Formatter instead. 69 72 def render_data_by_row(options={},&block) 70 73 data.each do |r| ruport/branches/brian/exp-stage-data-2/lib/ruport/formatter/csv.rb
r1260 r1275 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/branches/brian/exp-stage-data-2/lib/ruport/formatter/html.rb
r1226 r1275 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/branches/brian/exp-stage-data-2/lib/ruport/formatter/text.rb
r1251 r1275 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
