Class: Locale::TagList

Inherits:
Array
  • Object
show all
Defined in:
lib/locale/taglist.rb

Overview

This provides the subclass of Array which behaves like the first(top priority) Locale::Tag object. “Locale.current.language” is same with “Locale.current.language”.

Locale.current returns an Array of Tag(s) now. But the old Locale.current(Ruby-GetText) and Locale.get returns Locale::Object (similier with Locale::Tag::Posix). This is the class for backward compatibility.

It is recommanded to use Locale.current or Locale.candidates to find the current locale instead of this function.

Instance Method Summary collapse

Instance Method Details

#charsetObject

Returns the top priority charset. (posix)



44
45
46
47
48
49
50
# File 'lib/locale/taglist.rb', line 44

def charset
  if self[0].respond_to? :charset
    self[0].charset
  else
    ::Locale.driver_module.charset
  end
end

#countryObject

Returns the top priority region/country. (simple)



32
33
34
# File 'lib/locale/taglist.rb', line 32

def country
  self[0].region
end

#extensionsObject

Returns the top priority extensions.(common, rfc, cldr)



56
57
58
# File 'lib/locale/taglist.rb', line 56

def extensions
  (self[0].respond_to? :extensions) ? self[0].extensions : nil
end

#languageObject

Returns the top priority language. (simple)



28
29
30
# File 'lib/locale/taglist.rb', line 28

def language
  self[0].language
end

#modifierObject

Returns the top priority modifier. (posix)



52
53
54
# File 'lib/locale/taglist.rb', line 52

def modifier
  (self[0].respond_to? :modifier) ? self[0].modifier : nil
end

#privateuseObject

Returns the top priority privateuse(rfc)



60
61
62
# File 'lib/locale/taglist.rb', line 60

def privateuse
  (self[0].respond_to? :privateuse) ? self[0].privateuse : nil
end

#regionObject

Returns the top priority region/country. (simple)



36
37
38
# File 'lib/locale/taglist.rb', line 36

def region
  self[0].region
end

#scriptObject

Returns the top priority script. (common)



40
41
42
# File 'lib/locale/taglist.rb', line 40

def script
  self[0].script
end

#to_cldrObject



84
85
86
# File 'lib/locale/taglist.rb', line 84

def to_cldr
  self[0].to_cldr
end

#to_commonObject



72
73
74
# File 'lib/locale/taglist.rb', line 72

def to_common
  self[0].to_common
end

#to_posixObject



88
89
90
# File 'lib/locale/taglist.rb', line 88

def to_posix
  self[0].to_posix
end

#to_rfcObject



80
81
82
# File 'lib/locale/taglist.rb', line 80

def to_rfc
  self[0].to_rfc
end

#to_sObject



68
69
70
# File 'lib/locale/taglist.rb', line 68

def to_s
  self[0].to_s
end

#to_simpleObject



76
77
78
# File 'lib/locale/taglist.rb', line 76

def to_simple
  self[0].to_simple
end

#to_strObject



64
65
66
# File 'lib/locale/taglist.rb', line 64

def to_str
  self[0].to_str
end