Class: GovukComponent::HeaderComponent::ProductName
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::HeaderComponent::ProductName
- Defined in:
- app/components/govuk_component/header_component.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name: nil, html_attributes: {}, classes: []) ⇒ ProductName
constructor
A new instance of ProductName.
- #render? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(name: nil, html_attributes: {}, classes: []) ⇒ ProductName
Returns a new instance of ProductName.
112 113 114 115 116 |
# File 'app/components/govuk_component/header_component.rb', line 112 def initialize(name: nil, html_attributes: {}, classes: []) @name = name super(classes:, html_attributes:) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
110 111 112 |
# File 'app/components/govuk_component/header_component.rb', line 110 def name @name end |
Instance Method Details
#call ⇒ Object
122 123 124 125 126 127 128 |
# File 'app/components/govuk_component/header_component.rb', line 122 def call if content? tag.div(content, **html_attributes) else tag.span(name, **html_attributes) end end |
#render? ⇒ Boolean
118 119 120 |
# File 'app/components/govuk_component/header_component.rb', line 118 def render? name.present? || content? end |