Class: Locale::Tag::Rfc

### Home Classes Methods

### In Files

- lib/locale/tag/rfc.rb

### Parent

Locale::Tag::Common

### Methods

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

### Class/Module Index

Quicksearch

- Locale
- Locale::Driver
- Locale::Driver::CGI
- Locale::Driver::Env
- Locale::Driver::Env::Private
- 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

No matching classes.

# Locale::Tag::Rfc

Language tag class for RFC4646(BCP47).

### Constants

EXTENSION
GRANDFATHERED
PRIVATEUSE
SINGLETON
TAG_RE
VARIANT

### Attributes

extensions[R]
privateuse[R]

### Public Class Methods

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

    # File lib/locale/tag/rfc.rb, line 59
    def initialize(language, script = nil, region = nil, variants = [],
                 extensions = [], privateuse = nil)
      @extensions, @privateuse = extensions, privateuse
      super(language, script, region, variants)
    end

parse(tag) click to toggle source

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

    # File lib/locale/tag/rfc.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 = []
        variants = []
        if subtag =~ /#{PRIVATEUSE}/
            subtag, privateuse = $`, $1
          # Private use for CLDR.
          if /x-ldml(.*)/ =~ privateuse
            p_subtag = $1
            extensions = p_subtag.scan(/(^|-)#{EXTENSION}/).collect{|v| p_subtag.sub!(v[1], ""); v[1]}
            variants = p_subtag.scan(/(^|-)#{VARIANT}(?=(-|$))/).collect{|v| v[1]}
          end
        end
        extensions += subtag.scan(/(^|-)#{EXTENSION}/).collect{|v| subtag.sub!(v[1], ""); v[1]}
        variants += subtag.scan(/(^|-)#{VARIANT}(?=(-|$))/).collect{|v| v[1]}

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

### Public Instance Methods

extensions=(val) click to toggle source

Sets the extensions as an Array.

    # File lib/locale/tag/rfc.rb, line 66
    def extensions=(val)
      @extensions = val
    end

privateuse=(val) click to toggle source

Sets the privateuse as a String

    # File lib/locale/tag/rfc.rb, line 71
    def privateuse=(val)
      @privateuse = val
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.