Class: SortingTableFor::FormatLine
- Inherits:
-
TableBuilder
- Object
- TableBuilder
- SortingTableFor::FormatLine
- Defined in:
- lib/sorting_table_for/format_line.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#add_cell(object, args, type = nil, block = nil) ⇒ Object
Create a new cell with the class FormatCell Add the object in @cells.
-
#initialize(args, column_options = {}, html_options = {}, object = nil, type = nil) ⇒ FormatLine
constructor
A new instance of FormatLine.
-
#render_line ⇒ Object
Return a tr line based on the type (:thead, :tbody or :tfoot).
-
#total_cells ⇒ Object
Return the number of cells in line.
Methods inherited from TableBuilder
#caption, #column, #columns, #footer, #footers, #header, #headers
Constructor Details
#initialize(args, column_options = {}, html_options = {}, object = nil, type = nil) ⇒ FormatLine
Returns a new instance of FormatLine.
4 5 6 7 8 9 10 11 |
# File 'lib/sorting_table_for/format_line.rb', line 4 def initialize(args, = {}, = {}, object = nil, type = nil) @args, @column_options, @html_options, @object, @type = args, , , object, type @cells = [] if object @attributes = (args.empty?) ? (get_columns - TableBuilder.reserved_columns) : @args create_cells end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SortingTableFor::TableBuilder
Instance Method Details
#add_cell(object, args, type = nil, block = nil) ⇒ Object
Create a new cell with the class FormatCell Add the object in @cells
15 16 17 |
# File 'lib/sorting_table_for/format_line.rb', line 15 def add_cell(object, args, type = nil, block = nil) @cells << FormatCell.new(object, args, type, block) end |
#render_line ⇒ Object
Return a tr line based on the type (:thead, :tbody or :tfoot)
20 21 22 23 24 25 26 27 28 |
# File 'lib/sorting_table_for/format_line.rb', line 20 def render_line if @type == :thead return content_tag(:tr, Tools::html_safe(@cells.collect { |cell| cell.render_cell_thead }.join), @html_options) elsif @type == :tfoot return content_tag(:tr, Tools::html_safe(@cells.collect { |cell| cell.render_cell_tfoot }.join), @html_options) else content_tag(:tr, Tools::html_safe(@cells.collect { |cell| cell.render_cell_tbody }.join), @html_options.merge(:class => "#{@html_options[:class]} #{@@template.cycle(:odd, :even)}".strip)) end end |
#total_cells ⇒ Object
Return the number of cells in line
31 32 33 |
# File 'lib/sorting_table_for/format_line.rb', line 31 def total_cells @cells.size end |