Class: GovukComponent::ExitThisPageComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/exit_this_page_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(redirect_url: nil, href: nil, text: config.default_exit_this_page_text, activated_text: config.default_exit_this_page_activated_text, timed_out_text: config.default_exit_this_page_timed_out_text, press_two_more_times_text: config.default_exit_this_page_press_two_more_times_text, press_one_more_time_text: config.default_exit_this_page_press_one_more_time_text, classes: [], html_attributes: {}) ⇒ ExitThisPageComponent

Returns a new instance of ExitThisPageComponent.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/govuk_component/exit_this_page_component.rb', line 4

def initialize(
  redirect_url: nil,
  href: nil,
  text: config.default_exit_this_page_text,
  activated_text: config.default_exit_this_page_activated_text,
  timed_out_text: config.default_exit_this_page_timed_out_text,
  press_two_more_times_text: config.default_exit_this_page_press_two_more_times_text,
  press_one_more_time_text: config.default_exit_this_page_press_one_more_time_text,
  classes: [],
  html_attributes: {}
)
  fail(ArgumentError, "provide either redirect_url or href, not both") if redirect_url.present? && href.present?

  @text = text
  @redirect_url = href || redirect_url || config.default_exit_this_page_redirect_url || fail(ArgumentError, "no redirect_url provided")
  @activated_text = activated_text
  @timed_out_text = timed_out_text
  @press_two_more_times_text = press_two_more_times_text
  @press_one_more_time_text = press_one_more_time_text

  super(classes:, html_attributes:)
end

Instance Attribute Details

#activated_textObject (readonly)

Returns the value of attribute activated_text.



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

def activated_text
  @activated_text
end

#press_one_more_time_textObject (readonly)

Returns the value of attribute press_one_more_time_text.



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

def press_one_more_time_text
  @press_one_more_time_text
end

#press_two_more_times_textObject (readonly)

Returns the value of attribute press_two_more_times_text.



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

def press_two_more_times_text
  @press_two_more_times_text
end

#redirect_urlObject (readonly)

Returns the value of attribute redirect_url.



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

def redirect_url
  @redirect_url
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#timed_out_textObject (readonly)

Returns the value of attribute timed_out_text.



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

def timed_out_text
  @timed_out_text
end

Instance Method Details

#callObject



27
28
29
# File 'app/components/govuk_component/exit_this_page_component.rb', line 27

def call
  tag.div(exit_this_page_content, **html_attributes)
end