class RenderTable::Base

Attributes

header[RW]
html[RW]
options[RW]
override[RW]
records[RW]
table_class[RW]
table_id[RW]

Public Class Methods

new(args = {}) click to toggle source
# File lib/render_table/base.rb, line 14
def initialize(args = {})
  @records     = args[:records]     || []
  @header      = args[:header]      || []
  @override    = args[:override]    || {}
  @table_id    = args[:table_id]    || RenderTable.config.table_id
  @table_class = args[:table_class] || RenderTable.config.table_class
  @html        = args[:html]        || RenderTable.config.html
  @options     = args[:options]
end
render(args = {}) { |table| ... } click to toggle source
# File lib/render_table/base.rb, line 8
def self.render(args = {})
  table = new(args)
  yield table
  table.render
end

Public Instance Methods

context() click to toggle source
# File lib/render_table/base.rb, line 32
def context
  binding
end
render() click to toggle source
# File lib/render_table/base.rb, line 28
def render
  ERB.new(template, 0, '%<>').result(binding)
end
rows() click to toggle source
# File lib/render_table/base.rb, line 24
def rows
  RenderTable::Row.rows_for_table(self)
end

Private Instance Methods

options_cell(record, index) click to toggle source
# File lib/render_table/base.rb, line 42
def options_cell(record, index)
  RenderTable::Options.generate(table, @options, record, index)
end
table() click to toggle source
# File lib/render_table/base.rb, line 38
def table
  self
end
template() click to toggle source
# File lib/render_table/base.rb, line 46
  def template
    <<-ERB
      <% table.rows.each do |row| %>
      <% row.cells.each do |cell| %>
      <%= cell.value %>
      <% end %>
      <% end %>
    ERB
  end