Class: GovukComponent::ServiceNavigationComponent::ServiceNameComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/service_navigation_component/service_name_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(service_name:, service_url: nil, classes: [], html_attributes: {}) ⇒ ServiceNameComponent

Returns a new instance of ServiceNameComponent.



4
5
6
7
8
9
# File 'app/components/govuk_component/service_navigation_component/service_name_component.rb', line 4

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

  super(classes:, html_attributes:)
end

Instance Attribute Details

#service_nameObject (readonly)

Returns the value of attribute service_name.



2
3
4
# File 'app/components/govuk_component/service_navigation_component/service_name_component.rb', line 2

def service_name
  @service_name
end

#service_urlObject (readonly)

Returns the value of attribute service_url.



2
3
4
# File 'app/components/govuk_component/service_navigation_component/service_name_component.rb', line 2

def service_url
  @service_url
end

Instance Method Details

#callObject



11
12
13
14
15
# File 'app/components/govuk_component/service_navigation_component/service_name_component.rb', line 11

def call
  text = (service_url.present?) ? build_link : build_span

  tag.span(text, **html_attributes)
end