Class: DesignSystem::Components::TableRowBuilder
- Inherits:
-
Object
- Object
- DesignSystem::Components::TableRowBuilder
- Defined in:
- lib/design_system/components/table.rb
Overview
This class helps in building the row for the table <tr>
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
Instance Method Summary collapse
- #add_cell(content = nil, options = {}, &block) ⇒ Object
-
#initialize(columns) ⇒ TableRowBuilder
constructor
A new instance of TableRowBuilder.
Constructor Details
#initialize(columns) ⇒ TableRowBuilder
Returns a new instance of TableRowBuilder.
42 43 44 45 |
# File 'lib/design_system/components/table.rb', line 42 def initialize(columns) @cells = [] @columns = columns end |
Instance Attribute Details
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
40 41 42 |
# File 'lib/design_system/components/table.rb', line 40 def cells @cells end |
Instance Method Details
#add_cell(content = nil, options = {}, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/design_system/components/table.rb', line 47 def add_cell(content = nil, = {}, &block) if block_given? = content || {} content = block end index = @cells.size if index >= @columns.size raise ArgumentError, "Too many cells in row (expected at most #{@columns.size}, got #{index + 1})" end if @columns[index][:options][:type] == 'numeric' = { type: 'numeric' } = .merge() end @cells << { content:, options: } end |