Class: R18n::UnsupportedLocale
- Inherits:
-
Object
- Object
- R18n::UnsupportedLocale
- Defined in:
- lib/r18n-core/unsupported_locale.rb
Overview
Locale without information file. Contain only it code, empty title and data from default locale.
Instance Attribute Summary collapse
-
#base ⇒ Object
Locale, to get data and pluralization for unsupported locale.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#downcased_code ⇒ Object
readonly
Returns the value of attribute downcased_code.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Is another locale has same code.
-
#initialize(code, _base = nil) ⇒ UnsupportedLocale
constructor
Create object for unsupported locale with ‘code` and load other locale data from `base` locale.
-
#inspect ⇒ Object
Human readable locale code and title.
-
#method_missing(name, *params) ⇒ Object
Proxy to default locale object.
- #respond_to_missing?(name, *args) ⇒ Boolean
-
#supported? ⇒ Boolean
Is locale has information file.
-
#title ⇒ Object
Locale code as title.
Constructor Details
#initialize(code, _base = nil) ⇒ UnsupportedLocale
Create object for unsupported locale with ‘code` and load other locale data from `base` locale.
31 32 33 34 35 |
# File 'lib/r18n-core/unsupported_locale.rb', line 31 def initialize(code, _base = nil) @code = code @downcased_code = @code.downcase.tr('-', '_').freeze @base = Locale.load(I18n.default) if @code != I18n.default end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params) ⇒ Object
Proxy to default locale object.
58 59 60 61 62 |
# File 'lib/r18n-core/unsupported_locale.rb', line 58 def method_missing(name, *params) return super unless @base.respond_to? name @base.public_send(name, *params) end |
Instance Attribute Details
#base ⇒ Object
Locale, to get data and pluralization for unsupported locale.
25 26 27 |
# File 'lib/r18n-core/unsupported_locale.rb', line 25 def base @base end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
27 28 29 |
# File 'lib/r18n-core/unsupported_locale.rb', line 27 def code @code end |
#downcased_code ⇒ Object (readonly)
Returns the value of attribute downcased_code.
27 28 29 |
# File 'lib/r18n-core/unsupported_locale.rb', line 27 def downcased_code @downcased_code end |
Instance Method Details
#==(other) ⇒ Object
Is another locale has same code.
53 54 55 |
# File 'lib/r18n-core/unsupported_locale.rb', line 53 def ==(other) @code.casecmp(other.code).zero? end |
#inspect ⇒ Object
Human readable locale code and title.
43 44 45 |
# File 'lib/r18n-core/unsupported_locale.rb', line 43 def inspect "Unsupported locale #{@code}" end |
#respond_to_missing?(name, *args) ⇒ Boolean
64 65 66 |
# File 'lib/r18n-core/unsupported_locale.rb', line 64 def respond_to_missing?(name, *args) @base.send __method__, name, *args end |
#supported? ⇒ Boolean
Is locale has information file. In this class always return false.
38 39 40 |
# File 'lib/r18n-core/unsupported_locale.rb', line 38 def supported? false end |
#title ⇒ Object
Locale code as title.
48 49 50 |
# File 'lib/r18n-core/unsupported_locale.rb', line 48 def title @code end |