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
Attributes included from Traits::CustomHtmlAttributes
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name: nil, html_attributes: {}, classes: []) ⇒ ProductName
constructor
A new instance of ProductName.
- #render? ⇒ Boolean
Methods included from Traits::CustomClasses
Methods included from Govuk::Components::Helpers::CssUtilities
Constructor Details
#initialize(name: nil, html_attributes: {}, classes: []) ⇒ ProductName
Returns a new instance of ProductName.
99 100 101 102 103 |
# File 'app/components/govuk_component/header_component.rb', line 99 def initialize(name: nil, html_attributes: {}, classes: []) super(classes: classes, html_attributes: html_attributes) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
97 98 99 |
# File 'app/components/govuk_component/header_component.rb', line 97 def name @name end |
Instance Method Details
#call ⇒ Object
109 110 111 112 113 114 115 |
# File 'app/components/govuk_component/header_component.rb', line 109 def call if content.present? tag.div(content, class: classes) else tag.span(name, class: classes) end end |
#render? ⇒ Boolean
105 106 107 |
# File 'app/components/govuk_component/header_component.rb', line 105 def render? name.present? || content.present? end |