Sha256: fa8936486f48cdfb8416f3c0dc1fd79b4d45336ddd6bc81a3cec3314e559cdb9

Contents?: true

Size: 998 Bytes

Versions: 5

Compression:

Stored size: 998 Bytes

Contents

require 'date'

# table methods ######################################################
class HtmlSkeleton
 protected
  def table_header(cols)
    legend       = @options[:legend]
    th_attribute = @options[:th_attribute]
    return ''  unless legend

    proc = @options[:col_legend]
    col_header = cols.collect { |col|
      "<th #{th_attribute.call(col)}>#{proc.call(col)}</th>"
    }.join
    %Q{<thead><th class="legend">#{legend}</th>#{col_header}</thead>}
  end

  def table_body(rows, cols)
    legend       = @options[:legend]
    row_legend   = @options[:row_legend]
    tr_attribute = @options[:tr_attribute]
    rows.collect { |row|
      rlegend = legend ? %Q{<td class="legend">#{row_legend.call(row)}</td>}
		       : ''
      cells = table_row(row, cols)
      %Q{<tr #{tr_attribute.call(row)}>#{rlegend}#{cells}</tr>}
    }.join("\n")
  end

  def table_row(row, cols)
    cell_proc = @options[:cell_proc]
    cols.collect { |col|  cell_proc.call(row, col) }.join('')
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
html_skeleton-0.4.4 lib/html_skeleton_table.rb
html_skeleton-0.4.3 lib/html_skeleton_table.rb
html_skeleton-0.4.1 lib/html_skeleton_table.rb
html_skeleton-0.3.6 lib/html_skeleton_table.rb
html_skeleton-0.3.4 lib/html_skeleton_table.rb