Class: GovukComponent::ServiceNavigationComponent::ServiceNameComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::ServiceNavigationComponent::ServiceNameComponent
- Defined in:
- app/components/govuk_component/service_navigation_component/service_name_component.rb
Instance Attribute Summary collapse
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
#service_url ⇒ Object
readonly
Returns the value of attribute service_url.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(service_name:, service_url: nil, classes: [], html_attributes: {}) ⇒ ServiceNameComponent
constructor
A new instance of ServiceNameComponent.
Methods inherited from Base
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_name ⇒ Object (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_url ⇒ Object (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
#call ⇒ Object
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 |