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, #class_prefix

Constructor Details

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

Returns a new instance of ProductName.



49
50
51
52
53
# File 'app/components/govuk_component/header_component.rb', line 49

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.



47
48
49
# File 'app/components/govuk_component/header_component.rb', line 47

def name
  @name
end

Instance Method Details

#callObject



59
60
61
62
63
64
65
# File 'app/components/govuk_component/header_component.rb', line 59

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

#render?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/components/govuk_component/header_component.rb', line 55

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