class RenderTable::Cell

Attributes

cell_index[RW]
header[RW]
html[RW]

Public Class Methods

cells_for_row(row, table) click to toggle source
# File lib/render_table/cell.rb, line 4
def self.cells_for_row(row, table)
  table.header.collect.with_index do |header_cell, cell_index|
    RenderTable::Cell.new(header_cell, row, cell_index, table)
  end
end
new(header, row, cell_index, table) click to toggle source
# File lib/render_table/cell.rb, line 10
def initialize(header, row, cell_index, table)
  @header = header
  @row = row
  @cell_index = cell_index
  @table = table
  @html = @table.html[:cells]
end

Public Instance Methods

class() click to toggle source
# File lib/render_table/cell.rb, line 26
def class
  RenderTable::Html.html_string(@html[:classes], value, @cell_index)
end
id() click to toggle source
# File lib/render_table/cell.rb, line 30
def id
  RenderTable::Html.html_string(@html[:ids], value, @cell_index)
end
value() click to toggle source
# File lib/render_table/cell.rb, line 18
def value
  record = @row.record
  overriden_header = @table.override[header]
  return overriden_header.call(record, @cell_index) if overriden_header
  return record.send(header) if @row.record.respond_to? header
  RenderTable.config.cell_value
end