Class: GovukComponent::TaskListComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/task_list_component.rb

Defined Under Namespace

Classes: ItemComponent, StatusComponent, TitleComponent

Instance Attribute Summary

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

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

#callObject



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