Class: Locale::Tag::Posix

### Home Classes Methods

### In Files

- lib/locale/tag/posix.rb

### Parent

Locale::Tag::Simple

### Methods

- ::new
- ::parse
- #candidates
- #charset=
- #modifier=
- #to_s

### Class/Module Index

Quicksearch

- Locale
- Locale::Driver
- Locale::Driver::CGI
- Locale::Driver::Env
- Locale::Driver::JRuby
- Locale::Driver::Posix
- Locale::Driver::Win32
- Locale::Driver::Win32::Kernel32
- Locale::Driver::Win32Table
- Locale::Info
- Locale::Info::Language
- Locale::Info::Region
- Locale::Middleware
- Locale::Tag
- Locale::Tag::Cldr
- Locale::Tag::Common
- Locale::Tag::Irregular
- Locale::Tag::Posix
- Locale::Tag::Rfc
- Locale::Tag::Simple
- Locale::TagList
- Locale::Util
- Locale::Util::Memoizable

No matching classes.

# 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

LANGUAGE
TAG_RE

### Attributes

charset[R]
modifier[R]

### Public Class Methods

new(language, region = nil, charset = nil, modifier = nil) click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.