Class: Locale::Tag::Posix
Locale tag class for POSIX locale
- ja
- ja_JP
- ja_JP.UTF-8
- ja_JP.UTF-8@Osaka
- C/POSIX (-> en_US)
Constants
Name | Value |
---|---|
LANGUAGE | "([a-z]{2,})" |
TAG_RE | /\A#{LANGUAGE}(?:_#{REGION})?(?:\.([^@]+))?(?:@(.*))?\Z/i |
Attributes
Name | Read/write? |
---|---|
charset | R |
modifier | R |
Public Class Methods
new (language, region = nil, charset = nil, modifier = nil)
# File lib/locale/tag/posix.rb, line 27 27: def initialize(language, region = nil, charset = nil, modifier = nil) 28: @charset, @modifier = charset, modifier 29: super(language, region) 30: end
parse (tag)
# File lib/locale/tag/posix.rb, line 32 32: def self.parse(tag) 33: if tag =~ /^(C|POSIX)$/ 34: ret = self.new("en", "US") 35: ret.tag = tag 36: ret 37: elsif tag =~ TAG_RE 38: ret = self.new($1, $2, $3, $4) 39: ret.tag = tag 40: ret 41: else 42: nil 43: end 44: end
Public Instance Methods
candidates ()
Returns an Array of tag-candidates order by priority. Use Locale.candidates instead of this method.
# File lib/locale/tag/posix.rb, line 71 71: def candidates 72: [self.class.new(language, region, charset, modifier), #ja_JP.UTF-8@Modifier 73: self.class.new(language, region, charset), #ja_JP.UTF-8 74: self.class.new(language, region, nil, modifier), #ja_JP@Modifier 75: self.class.new(language, region, nil, nil), #ja_JP@Modifier 76: self.class.new(language, nil, charset, modifier), #ja.UTF-8@Modifier 77: self.class.new(language, nil, charset), #ja.UTF-8 78: self.class.new(language, nil, nil, modifier), #ja@Modifier 79: self.class.new(language)] #ja 80: end
charset= (val)
Set the charset.
# File lib/locale/tag/posix.rb, line 58 58: def charset=(val) 59: clear 60: @charset = val 61: end
modifier= (val)
Set the modifier as a String
# File lib/locale/tag/posix.rb, line 64 64: def modifier=(val) 65: clear 66: @modifier = val 67: end
to_s ()
Returns the language tag.
<language>_<COUNTRY>.<CHARSET>@<MODIFIER> (e.g.) "ja_JP.EUC-JP@Modifier"
# File lib/locale/tag/posix.rb, line 49 49: def to_s 50: s = @language.dup 51: s << "_#{@region}" if @region 52: s << ".#{@charset}" if @charset 53: s << "@#{@modifier}" if @modifier 54: s 55: end