Class: Maglev::Uikit::LocaleSwitcherComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Maglev::Uikit::LocaleSwitcherComponent
- Defined in:
- app/components/maglev/uikit/locale_switcher_component.rb
Instance Attribute Summary collapse
-
#current_locale ⇒ Object
readonly
Returns the value of attribute current_locale.
-
#locales ⇒ Object
readonly
Returns the value of attribute locales.
Instance Method Summary collapse
- #current_locale_label ⇒ Object
-
#initialize(locales:, current_locale:) ⇒ LocaleSwitcherComponent
constructor
A new instance of LocaleSwitcherComponent.
Methods inherited from BaseComponent
Constructor Details
#initialize(locales:, current_locale:) ⇒ LocaleSwitcherComponent
Returns a new instance of LocaleSwitcherComponent.
8 9 10 11 |
# File 'app/components/maglev/uikit/locale_switcher_component.rb', line 8 def initialize(locales:, current_locale:) @locales = locales @current_locale = current_locale.to_s end |
Instance Attribute Details
#current_locale ⇒ Object (readonly)
Returns the value of attribute current_locale.
6 7 8 |
# File 'app/components/maglev/uikit/locale_switcher_component.rb', line 6 def current_locale @current_locale end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
6 7 8 |
# File 'app/components/maglev/uikit/locale_switcher_component.rb', line 6 def locales @locales end |
Instance Method Details
#current_locale_label ⇒ Object
13 14 15 |
# File 'app/components/maglev/uikit/locale_switcher_component.rb', line 13 def current_locale_label locales.find { |locale| locale[:value].to_s == current_locale }[:label] end |