Changeset 1281

Show
Ignore:
Timestamp:
02/20/08 08:30:09 (9 months ago)
Author:
brian
Message:

build_row takes optional data argument, and table building uses this directly. render_data_by_row is removed. Closes #381

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ruport/trunk/lib/ruport/formatter.rb

    r1262 r1281  
    6565    # 
    6666    module RenderingTools 
    67       # Iterates through <tt>data</tt> and passes 
    68       # 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         end 
    73       end 
    74  
    7567      # Uses Renderer::Row to render the Row object with the 
    7668      # given options. 
  • ruport/trunk/lib/ruport/formatter/csv.rb

    r1260 r1281  
    7979 
    8080    # Produces CSV output for a data row. 
    81     def build_row 
     81    def build_row(data = self.data) 
    8282      csv_writer << data 
    8383    end 
  • ruport/trunk/lib/ruport/formatter/html.rb

    r1277 r1281  
    5252    # Replaces nil and empty strings with "&nbsp;"  
    5353    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? ? "&nbsp;" : e } 
     54      data.each do |row| 
     55        build_row(row.map { |e| e.to_s.empty? ? "&nbsp;" : e }) 
    5756      end 
    5857    end 
     
    6463   
    6564    # Renders individual rows for the table. 
    66     def build_row 
     65    def build_row(data = self.data) 
    6766      output << 
    6867        "\t\t<tr>\n\t\t\t<td>" + 
  • ruport/trunk/lib/ruport/formatter/text.rb

    r1251 r1281  
    9595      calculate_max_col_widths unless options.max_col_width 
    9696 
    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) } 
    10598 
    10699      output << fit_to_width(hr) 
     
    115108    # Uses fit_to_width to truncate the row if necessary. 
    116109    # 
    117     def build_row 
     110    def build_row(data = self.data) 
    118111      max_col_widths_for_row(data) unless options.max_col_width 
    119112