Class: RenderTable::Cell
- Inherits:
-
Object
- Object
- RenderTable::Cell
- Defined in:
- lib/render_table/cell.rb
Instance Attribute Summary collapse
-
#cell_index ⇒ Object
Returns the value of attribute cell_index.
-
#header ⇒ Object
Returns the value of attribute header.
-
#html ⇒ Object
Returns the value of attribute html.
Class Method Summary collapse
Instance Method Summary collapse
- #class ⇒ Object
- #id ⇒ Object
-
#initialize(header, row, cell_index, table) ⇒ Cell
constructor
A new instance of Cell.
- #value ⇒ Object
Constructor Details
#initialize(header, row, cell_index, table) ⇒ Cell
Returns a new instance of Cell.
10 11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#cell_index ⇒ Object
Returns the value of attribute cell_index.
2 3 4 |
# File 'lib/render_table/cell.rb', line 2 def cell_index @cell_index end |
#header ⇒ Object
Returns the value of attribute header.
2 3 4 |
# File 'lib/render_table/cell.rb', line 2 def header @header end |
#html ⇒ Object
Returns the value of attribute html.
2 3 4 |
# File 'lib/render_table/cell.rb', line 2 def html @html end |
Class Method Details
.cells_for_row(row, table) ⇒ Object
4 5 6 7 8 |
# 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 |
Instance Method Details
#class ⇒ Object
26 27 28 |
# File 'lib/render_table/cell.rb', line 26 def class RenderTable::Html.html_string(@html[:classes], value, @cell_index) end |
#id ⇒ Object
30 31 32 |
# File 'lib/render_table/cell.rb', line 30 def id RenderTable::Html.html_string(@html[:ids], value, @cell_index) end |
#value ⇒ Object
18 19 20 21 22 23 24 |
# 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 |