Class: GovukPublishingComponents::Presenters::SelectHelper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_assigns) ⇒ SelectHelper

Returns a new instance of SelectHelper.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 6

def initialize(local_assigns)
  @options = local_assigns[:options] || []
  @error_message = local_assigns[:error_message]
  @error_id = local_assigns[:error_id] || nil
  @hint = local_assigns[:hint] || nil
  @hint_id = local_assigns[:hint_id] || nil
  @heading_size = local_assigns[:heading_size]
  @full_width = local_assigns[:full_width] || false
  @option_markup = get_options
  @describedby = get_describedby
end

Instance Attribute Details

#describedbyObject (readonly)

Returns the value of attribute describedby.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def describedby
  @describedby
end

#error_idObject (readonly)

Returns the value of attribute error_id.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def error_id
  @error_id
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def error_message
  @error_message
end

#hintObject (readonly)

Returns the value of attribute hint.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def hint
  @hint
end

#hint_idObject (readonly)

Returns the value of attribute hint_id.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def hint_id
  @hint_id
end

#option_markupObject (readonly)

Returns the value of attribute option_markup.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def option_markup
  @option_markup
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def options
  @options
end

#selected_optionObject (readonly)

Returns the value of attribute selected_option.



4
5
6
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 4

def selected_option
  @selected_option
end

Instance Method Details

#css_classesObject



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

def css_classes
  classes = %w[govuk-form-group gem-c-select]
  classes << "govuk-form-group--error" if @error_message
  classes
end

#label_classesObject



31
32
33
34
35
# File 'lib/govuk_publishing_components/presenters/select_helper.rb', line 31

def label_classes
  classes = %w[govuk-label]
  classes << "govuk-label--#{@heading_size}" if @heading_size
  classes
end

#select_classesObject



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

def select_classes
  classes = %w[govuk-select]
  classes << "gem-c-select__select--full-width" if @full_width
  classes << "govuk-select--error" if @error_id
  classes
end