class RenderTable::Base
Attributes
header[RW]
html[RW]
options[RW]
override[RW]
records[RW]
table_class[RW]
table_id[RW]
timestamps[RW]
Public Class Methods
new(args = {})
click to toggle source
# File lib/render_table/base.rb, line 15 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 @timestamps ||= true @options = args[:options] end
render(args = {}) { |table| ... }
click to toggle source
# File lib/render_table/base.rb, line 9 def self.render(args = {}) table = new(args) yield table table.render.html_safe end
Public Instance Methods
context()
click to toggle source
# File lib/render_table/base.rb, line 34 def context binding end
render()
click to toggle source
# File lib/render_table/base.rb, line 30 def render ERB.new(template, 0, '%<>').result(binding) end
rows()
click to toggle source
# File lib/render_table/base.rb, line 26 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 44 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 40 def table self end
template()
click to toggle source
# File lib/render_table/base.rb, line 48 def template <<-ERB <% table.rows.each do |row| %> <% row.cells.each do |cell| %> <%= cell.value %> <% end %> <% end %> ERB end