Class: GovukComponent::HeaderComponent::ProductName

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

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Attributes included from Traits::CustomHtmlAttributes

#html_attributes

Instance Method Summary collapse

Methods included from Traits::CustomClasses

#classes

Methods included from Govuk::Components::Helpers::CssUtilities

#combine_classes

Constructor Details

#initialize(name: nil, html_attributes: {}, classes: []) ⇒ ProductName

Returns a new instance of ProductName.



117
118
119
120
121
# File 'app/components/govuk_component/header_component.rb', line 117

def initialize(name: nil, html_attributes: {}, classes: [])
  super(classes: classes, html_attributes: html_attributes)

  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



115
116
117
# File 'app/components/govuk_component/header_component.rb', line 115

def name
  @name
end

Instance Method Details

#callObject



127
128
129
130
131
132
133
# File 'app/components/govuk_component/header_component.rb', line 127

def call
  if content.present?
    tag.div(content, class: classes)
  else
    tag.span(name, class: classes)
  end
end

#render?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'app/components/govuk_component/header_component.rb', line 123

def render?
  name.present? || content.present?
end