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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ProductName.



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

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

  super(classes: classes, html_attributes: html_attributes)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#callObject



131
132
133
134
135
136
137
# File 'app/components/govuk_component/header_component.rb', line 131

def call
  if content.present?
    tag.div(content, **html_attributes)
  else
    tag.span(name, **html_attributes)
  end
end

#render?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'app/components/govuk_component/header_component.rb', line 127

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