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
Locale RFC 3066 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 frombase
locale. -
#inspect ⇒ Object
Human readable locale code and title.
-
#method_missing(name, *params) ⇒ Object
Proxy to default locale object.
-
#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.
29 30 31 32 |
# File 'lib/r18n-core/unsupported_locale.rb', line 29 def initialize(code, _base = nil) @code = code @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 |
# File 'lib/r18n-core/unsupported_locale.rb', line 58 def method_missing(name, *params) @base.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)
Locale RFC 3066 code.
45 46 47 |
# File 'lib/r18n-core/unsupported_locale.rb', line 45 def code @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.
40 41 42 |
# File 'lib/r18n-core/unsupported_locale.rb', line 40 def inspect "Unsupported locale #{@code}" end |
#supported? ⇒ Boolean
Is locale has information file. In this class always return false.
35 36 37 |
# File 'lib/r18n-core/unsupported_locale.rb', line 35 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 |