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

Methods inherited from Base

#brand

Constructor Details

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

Returns a new instance of ProductName.



104
105
106
107
108
# File 'app/components/govuk_component/header_component.rb', line 104

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

  super(classes:, html_attributes:)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



102
103
104
# File 'app/components/govuk_component/header_component.rb', line 102

def name
  @name
end

Instance Method Details

#callObject



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

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

#render?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'app/components/govuk_component/header_component.rb', line 110

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