Class: GovukPublishingComponents::Presenters::TranslationNavHelper
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::TranslationNavHelper
- Defined in:
- lib/govuk_publishing_components/presenters/translation_nav_helper.rb
Instance Attribute Summary collapse
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Method Summary collapse
- #classes ⇒ Object
- #has_translations? ⇒ Boolean
-
#initialize(local_assigns) ⇒ TranslationNavHelper
constructor
A new instance of TranslationNavHelper.
- #inverse_class ⇒ Object
- #margin_class ⇒ Object
- #tracking_is_present? ⇒ Boolean
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
#translations ⇒ Object (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
#classes ⇒ Object
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
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_class ⇒ Object
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_class ⇒ Object
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
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 |