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



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

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



31
32
33
# File 'lib/govuk_publishing_components/presenters/translation_nav_helper.rb', line 31

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

#margin_classObject



35
36
37
# File 'lib/govuk_publishing_components/presenters/translation_nav_helper.rb', line 35

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

#tracking_is_present?Boolean

Returns:

  • (Boolean)


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

def tracking_is_present?
  @translations.each do |translation|
    return true if translation[:data_attributes]
  end
  false
end