Class: GovukPublishingComponents::Presenters::InterventionHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_publishing_components/presenters/intervention_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(local_assigns) ⇒ InterventionHelper

Returns a new instance of InterventionHelper.



4
5
6
7
8
9
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 4

def initialize(local_assigns)
  @accessible_text_suffix = I18n.t("components.intervention.accessible_link_text_suffix")
  @query_string = local_assigns[:query_string]
  @suggestion_link_text = local_assigns[:suggestion_link_text]
  @suggestion_link_url = local_assigns[:suggestion_link_url]
end

Instance Method Details

#accessible_textObject



11
12
13
14
15
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 11

def accessible_text
  @suggestion_link_text << @accessible_text_suffix unless @suggestion_link_text.include?(@accessible_text_suffix)

  @suggestion_link_text
end


17
18
19
20
21
22
23
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 17

def dismiss_link
  if @query_string.present?
    "#{@query_string}&hide-intervention=true"
  else
    "?hide-intervention=true"
  end
end

#security_attrObject



25
26
27
28
29
30
# File 'lib/govuk_publishing_components/presenters/intervention_helper.rb', line 25

def security_attr
  rel = "noopener noreferrer"
  rel << " external" unless @suggestion_link_url.start_with?("/", "https://gov.uk", "https://www.gov.uk")

  rel
end