Class: Rtl
- Inherits:
-
Object
- Object
- Rtl
- Defined in:
- lib/rtl.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #css_class ⇒ Object
- #current_user_rtl? ⇒ Boolean
- #enabled? ⇒ Boolean
-
#initialize(user) ⇒ Rtl
constructor
A new instance of Rtl.
- #rtl_locales ⇒ Object
- #site_locale_rtl? ⇒ Boolean
Constructor Details
#initialize(user) ⇒ Rtl
Returns a new instance of Rtl.
6 7 8 |
# File 'lib/rtl.rb', line 6 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/rtl.rb', line 4 def user @user end |
Instance Method Details
#css_class ⇒ Object
26 27 28 |
# File 'lib/rtl.rb', line 26 def css_class enabled? ? "rtl" : "" end |
#current_user_rtl? ⇒ Boolean
14 15 16 |
# File 'lib/rtl.rb', line 14 def current_user_rtl? SiteSetting.allow_user_locale && (user&.locale || SiteSetting.default_locale).in?(rtl_locales) end |
#enabled? ⇒ Boolean
10 11 12 |
# File 'lib/rtl.rb', line 10 def enabled? site_locale_rtl? || current_user_rtl? end |
#rtl_locales ⇒ Object
22 23 24 |
# File 'lib/rtl.rb', line 22 def rtl_locales %w[he ar ur fa_IR] end |
#site_locale_rtl? ⇒ Boolean
18 19 20 |
# File 'lib/rtl.rb', line 18 def site_locale_rtl? !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(rtl_locales) end |