Class: GovukComponent::TaskListComponent
- Defined in:
- app/components/govuk_component/task_list_component.rb
Defined Under Namespace
Classes: ItemComponent, StatusComponent, TitleComponent
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(id_prefix: "task-list", classes: [], html_attributes: {}) ⇒ TaskListComponent
constructor
A new instance of TaskListComponent.
Methods inherited from Base
Constructor Details
#initialize(id_prefix: "task-list", classes: [], html_attributes: {}) ⇒ TaskListComponent
Returns a new instance of TaskListComponent.
16 17 18 19 20 21 |
# File 'app/components/govuk_component/task_list_component.rb', line 16 def initialize(id_prefix: "task-list", classes: [], html_attributes: {}) @id_prefix = id_prefix @count = 0 super(classes:, html_attributes:) end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/components/govuk_component/task_list_component.rb', line 23 def call numbered_items = items.each.with_index(1) { |item, count| item.count = count } tag.ul(**html_attributes) do safe_join(numbered_items) end end |