Class: GovukComponent::AccordionComponent
- Defined in:
- app/components/govuk_component/accordion_component.rb
Defined Under Namespace
Classes: SectionComponent
Instance Attribute Summary collapse
-
#accordion_id ⇒ Object
readonly
Returns the value of attribute accordion_id.
-
#heading_level ⇒ Object
readonly
Returns the value of attribute heading_level.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(heading_level: 2, classes: [], html_attributes: {}) ⇒ AccordionComponent
constructor
A new instance of AccordionComponent.
Methods inherited from Base
Constructor Details
#initialize(heading_level: 2, classes: [], html_attributes: {}) ⇒ AccordionComponent
Returns a new instance of AccordionComponent.
17 18 19 20 21 22 |
# File 'app/components/govuk_component/accordion_component.rb', line 17 def initialize(heading_level: 2, classes: [], html_attributes: {}) @heading_level = heading_tag(heading_level) @accordion_id = html_attributes[:id] super(classes:, html_attributes:) end |
Instance Attribute Details
#accordion_id ⇒ Object (readonly)
Returns the value of attribute accordion_id.
15 16 17 |
# File 'app/components/govuk_component/accordion_component.rb', line 15 def accordion_id @accordion_id end |
#heading_level ⇒ Object (readonly)
Returns the value of attribute heading_level.
15 16 17 |
# File 'app/components/govuk_component/accordion_component.rb', line 15 def heading_level @heading_level end |
Instance Method Details
#call ⇒ Object
24 25 26 |
# File 'app/components/govuk_component/accordion_component.rb', line 24 def call tag.div(**html_attributes) { safe_join(sections) } end |