Parent

Included Modules

Locale::Tag::Simple

Abstract language tag class. This class has , which all of language tag specifications have.

Constants

ALPHA
DIGIT
ALPHANUM
LANGUAGE
REGION
TAG_RE

Attributes

language[R]
region[R]
tag[RW]

tag is set when .parse method is called. This value is used when the program want to know the original String.

Public Class Methods

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

Create a Locale::Tag::Simple

    # File lib/locale/tag/simple.rb, line 75
75:       def initialize(language, region = nil)
76:         raise "language can't be nil." unless language
77:         @language, @region = language, region
78:         @language = @language.downcase if @language
79:         @region = @region.upcase if @region
80:       end
parse(tag) click to toggle source

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

    # File lib/locale/tag/simple.rb, line 62
62:         def parse(tag)
63:           if tag =~ TAG_RE
64:             ret = self.new($1, $2)
65:             ret.tag = tag
66:             ret
67:           else
68:             nil
69:           end
70:         end

Public Instance Methods

<=>(other) click to toggle source
    # File lib/locale/tag/simple.rb, line 94
94:       def <=>(other)
95:         self.to_s <=> other.to_s
96:       end
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/simple.rb, line 138
138:       def candidates
139:         [self.class.new(language, region), self.class.new(language)]
140:       end
country() click to toggle source

For backward compatibility.

     # File lib/locale/tag/simple.rb, line 118
118:       def country; region end
language=(val) click to toggle source

Set the language (with downcase)

     # File lib/locale/tag/simple.rb, line 121
121:       def language=(val)
122:         clear
123:         @language = val
124:         @language = @language.downcase if @language
125:         @language
126:       end
region=(val) click to toggle source

Set the region (with upcase)

     # File lib/locale/tag/simple.rb, line 129
129:       def region=(val)
130:         clear
131:         @region = val
132:         @region = @region.upcase if @region
133:         @region
134:       end
to_s() click to toggle source

Returns the language tag as the String.

  <language>_<REGION>
  (e.g.) "ja_JP"
    # File lib/locale/tag/simple.rb, line 85
85:       def to_s
86:         to_string
87:       end

Private Instance Methods

to_string() click to toggle source

Return simple language tag which format is”_”. This is to use internal only. Use to_s instead.

     # File lib/locale/tag/simple.rb, line 155
155:       def to_string  
156:         s = @language.dup
157:         s << "_" << @region if @region
158:         s      
159:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.