Class: Sandals::Table
- Inherits:
-
Object
- Object
- Sandals::Table
- Defined in:
- lib/sandals/view.rb
Constant Summary collapse
- FORBIDDEN_CELL_TYPES =
[ Container, TextField, NumberField, TextArea, Checkbox, Select, FileField, Button, Title, Subtitle, Para, Error, Notice, Image, Link ].freeze
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(headers:, rows:) ⇒ Table
constructor
A new instance of Table.
Constructor Details
#initialize(headers:, rows:) ⇒ Table
Returns a new instance of Table.
559 560 561 562 563 564 565 566 567 568 569 570 571 |
# File 'lib/sandals/view.rb', line 559 def initialize(headers:, rows:) @headers = collection(headers, "table headers").map(&:to_s).freeze @rows = collection(rows, "table rows").each_with_index.map do |row, index| cells = collection(row, "table row #{index + 1}") unless cells.length == @headers.length raise ArgumentError, "table row #{index + 1} has #{cells.length} cells, " \ "but #{@headers.length} headers were provided" end cells.map { |cell| normalize_cell(cell) }.freeze end.freeze end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
557 558 559 |
# File 'lib/sandals/view.rb', line 557 def headers @headers end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
557 558 559 |
# File 'lib/sandals/view.rb', line 557 def rows @rows end |