Included Modules

Locale::Tag::Rfc

Language tag class for RFC4646(BCP47).

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 61
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 32
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 68
def extensions=(val)
  clear
  @extensions = val
end
privateuse=(val) click to toggle source

Sets the privateuse as a String

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.