Class: Maglev::Uikit::LocaleSwitcherComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/maglev/uikit/locale_switcher_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#button_class_names

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_localeObject (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

#localesObject (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_labelObject



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