Class: DesignSystem::Components::SummaryList
- Inherits:
-
Object
- Object
- DesignSystem::Components::SummaryList
- Defined in:
- lib/design_system/components/summary_list.rb
Overview
This class provides a summary list component.
Instance Attribute Summary collapse
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#add_row(*args, key: nil, value: nil) {|row_builder| ... } ⇒ Object
Add a new row to the summary list.
-
#initialize ⇒ SummaryList
constructor
A new instance of SummaryList.
Constructor Details
#initialize ⇒ SummaryList
Returns a new instance of SummaryList.
9 10 11 |
# File 'lib/design_system/components/summary_list.rb', line 9 def initialize @rows = [] end |
Instance Attribute Details
#rows ⇒ Object
Returns the value of attribute rows.
7 8 9 |
# File 'lib/design_system/components/summary_list.rb', line 7 def rows @rows end |
Instance Method Details
#add_row(*args, key: nil, value: nil) {|row_builder| ... } ⇒ Object
Add a new row to the summary list. Use this method to add rows containing single key-value pair
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/design_system/components/summary_list.rb', line 15 def add_row(*args, key: nil, value: nil) key, value = args if args.any? row_builder = SummaryListRowBuilder.new row_builder.add_key(key) if key row_builder.add_value(value) if value yield(row_builder) if block_given? @rows << row_builder.row end |