Class: Locale::Tag::Cldr

### Home Classes Methods

### In Files

- lib/locale/tag/cldr.rb

### Parent

Locale::Tag::Common

### Methods

- ::new
- ::parse
- #extensions=

### Included Modules

- Locale::Util::Memoizable

### 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::Cldr

Unicode locale identifier class for CLDR-1.6.1. (Unicode Common Locale Data Repository).

### Constants

EXTENSION
TAG_RE
VARIANT

### Attributes

extensions[R]

### Public Class Methods

new(language, script = nil, region = nil, variants = [], extensions = {}) click to toggle source

Create Locale::Tag::Cldr.

variants should be upcase.

    # File lib/locale/tag/cldr.rb, line 58
    def initialize(language, script = nil, region = nil,
                   variants = [], extensions = {})
      @extensions = extensions
      super(language, script, region, variants.map{|v| v.upcase})
    end

parse(tag) click to toggle source

Parse the language tag and return the new Locale::Tag::CLDR.

    # File lib/locale/tag/cldr.rb, line 31
    def parse(tag)
      if tag =~ /\APOSIX\Z/  # This is the special case of POSIX locale but match this regexp.
        nil
      elsif tag =~ TAG_RE
        lang, script, region, subtag = $1, $2, $3, $4

        extensions = {}
        subtag.scan(/#{EXTENSION}/).each{|v|
          subtag.sub!(v, "")
          key, type = v.split("=")
          extensions[key] = type
        }
        variants = subtag.scan(/#{VARIANT}/).collect{|v| v[0].upcase}

        ret = self.new(lang, script, region, variants, extensions)
        ret.tag = tag
        ret
      else
        nil
      end
    end

### Public Instance Methods

extensions=(val) click to toggle source

Sets the extensions as an Hash.

    # File lib/locale/tag/cldr.rb, line 65
    def extensions=(val)
      clear
      @extensions = val
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.