Class: GovukPublishingComponents::Presenters::TranslationNavHelper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_assigns) ⇒ TranslationNavHelper

Returns a new instance of TranslationNavHelper.



6
7
8
9
10
11
# File 'lib/govuk_publishing_components/presenters/translation_nav_helper.rb', line 6

def initialize(local_assigns)
  @translations = []
  @translations = local_assigns[:translations] if local_assigns[:translations]
  @no_margin_top = local_assigns[:no_margin_top]
  @inverse = local_assigns[:inverse]
end

Instance Attribute Details

#translationsObject (readonly)

Returns the value of attribute translations.



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

def translations
  @translations
end

Instance Method Details

#classesObject



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

def classes
  classes = %w[gem-c-translation-nav]
  classes << inverse_class if @inverse
  classes << margin_class if @no_margin_top
  classes.join(" ")
end

#has_translations?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/govuk_publishing_components/presenters/translation_nav_helper.rb', line 13

def has_translations?
  true if @translations.length > 1
end

#inverse_classObject



24
25
26
# File 'lib/govuk_publishing_components/presenters/translation_nav_helper.rb', line 24

def inverse_class
  "gem-c-translation-nav--inverse"
end

#margin_classObject



28
29
30
# File 'lib/govuk_publishing_components/presenters/translation_nav_helper.rb', line 28

def margin_class
  "gem-c-translation-nav--no-margin-top"
end