class Locale::Tag::Posix
Locale tag class for POSIX locale
-
ja
-
ja_JP
-
ja_JP.UTF-8
-
ja_JP.UTF-8
-
C/POSIX (-> en_US)
Constants
- LANGUAGE
- TAG_RE
Attributes
charset[R]
modifier[R]
Public Class Methods
new(language, region = nil, charset = nil, modifier = nil)
click to toggle source
Calls superclass method
# File lib/locale/tag/posix.rb, line 27 def initialize(language, region = nil, charset = nil, modifier = nil) @charset, @modifier = charset, modifier super(language, region) end
parse(tag)
click to toggle source
# File lib/locale/tag/posix.rb, line 32 def self.parse(tag) if tag =~ /^(C|POSIX)$/ ret = self.new("en", "US") ret.tag = tag ret elsif tag =~ TAG_RE ret = self.new($1, $2, $3, $4) ret.tag = tag ret else nil end end
Public Instance Methods
candidates()
click to toggle source
Returns an Array of tag-candidates order by priority. Use Locale#candidates instead of this method.
# File lib/locale/tag/posix.rb, line 71 def candidates [self.class.new(language, region, charset, modifier), #ja_JP.UTF-8@Modifier self.class.new(language, region, charset), #ja_JP.UTF-8 self.class.new(language, region, nil, modifier), #ja_JP@Modifier self.class.new(language, region, nil, nil), #ja_JP@Modifier self.class.new(language, nil, charset, modifier), #ja.UTF-8@Modifier self.class.new(language, nil, charset), #ja.UTF-8 self.class.new(language, nil, nil, modifier), #ja@Modifier self.class.new(language)] #ja end
charset=(val)
click to toggle source
Set the charset.
# File lib/locale/tag/posix.rb, line 58 def charset=(val) clear @charset = val end
modifier=(val)
click to toggle source
Set the modifier as a String
# File lib/locale/tag/posix.rb, line 64 def modifier=(val) clear @modifier = val end
to_s()
click to toggle source
Returns the language tag.
<language>_<COUNTRY>.<CHARSET>@<MODIFIER> (e.g.) "ja_JP.EUC-JP@Modifier"
# File lib/locale/tag/posix.rb, line 49 def to_s s = @language.dup s << "_#{@region}" if @region s << ".#{@charset}" if @charset s << "@#{@modifier}" if @modifier s end
Private Instance Methods
convert_to(klass)
click to toggle source
A modifier is converted to a variant. If the modifier is less than 5 characters, it is not canonical value.
Calls superclass method
# File lib/locale/tag/posix.rb, line 85 def convert_to(klass) if klass == Simple super elsif klass == Posix klass.new(language, region, charset, modifier) else klass.new(language, nil, region, modifier ? [modifier] : []) end end