Class: RenderTable::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/render_table/row.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, row_index, table) ⇒ Row

Returns a new instance of Row.



11
12
13
14
15
16
# File 'lib/render_table/row.rb', line 11

def initialize(record, row_index, table)
  @record = record
  @row_index = row_index
  @table = table
  @html = @table.html[:rows]
end

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



3
4
5
# File 'lib/render_table/row.rb', line 3

def html
  @html
end

#recordObject

Returns the value of attribute record.



3
4
5
# File 'lib/render_table/row.rb', line 3

def record
  @record
end

#row_indexObject

Returns the value of attribute row_index.



3
4
5
# File 'lib/render_table/row.rb', line 3

def row_index
  @row_index
end

Class Method Details

.rows_for_table(table) ⇒ Object



5
6
7
8
9
# File 'lib/render_table/row.rb', line 5

def self.rows_for_table(table)
  table.records.collect.with_index do |record, row_index|
    RenderTable::Row.new(record, row_index, table)
  end
end

Instance Method Details

#cellsObject



26
27
28
# File 'lib/render_table/row.rb', line 26

def cells
  RenderTable::Cell.cells_for_row(self, @table)
end

#classObject



18
19
20
# File 'lib/render_table/row.rb', line 18

def class
  RenderTable::Html.html_string(@html[:classes], @record, @row_index)
end

#idObject



22
23
24
# File 'lib/render_table/row.rb', line 22

def id
  RenderTable::Html.html_string(@html[:ids], @record, @row_index)
end