class Locale::Tag::Simple

  • ja-392
    * ja-JP
    * ja_JP (country: RFC4646 (ISO3166/UN M.49) (2 alpha or 3 digit)
    * ja (language: ISO 639 (2 or 3 alpha))
    all of language tag specifications have.
    This class has <language>, <region> which
    Abstract language tag class.

def <=>(other)

def <=>(other)
  self.to_s <=> other.to_s
end

def ==(other) #:nodoc:

:nodoc:
def ==(other)  #:nodoc:
  other != nil and hash == other.hash
end

def candidates

Use Locale.candidates instead of this method.
Returns an Array of tag-candidates order by priority.
def candidates
  [self.class.new(language, region), self.class.new(language)]
end

def convert_to(klass) #:nodoc:

:nodoc:
def convert_to(klass)  #:nodoc:
  if klass == Simple || klass == Posix
    klass.new(language, region)
  else
    klass.new(language, nil, region)
  end
end

def country; region end

For backward compatibility.
def country; region end

def eql?(other) #:nodoc:

:nodoc:
def eql?(other) #:nodoc:
  self.==(other)
end

def hash #:nodoc:

:nodoc:
def hash #:nodoc:
  "#{self.class}:#{to_s}".hash
end

def initialize(language, region = nil)

Create a Locale::Tag::Simple
def initialize(language, region = nil)
  raise "language can't be nil." unless language
  @language, @region = language, region
  @language = @language.downcase if @language
  @region = @region.upcase if @region
end

def inspect #:nodoc:

:nodoc:
def inspect  #:nodoc:
  %Q[#<#{self.class}: #{to_s}>]
end

def language=(val)

Set the language (with downcase)
def language=(val)
  @language = val
  @language = @language.downcase if @language
  @language
end

def parse(tag)

Parse the language tag and return the new Locale::Tag::Simple.
def parse(tag)
  case tag
  when TAG_RE
    ret = self.new($1, $2)
    ret.tag = tag
    ret
  else
    nil
  end
end

def region=(val)

Set the region (with upcase)
def region=(val)
  @region = val
  @region = @region.upcase if @region
  @region
end

def to_s

(e.g.) "ja_JP"
_
Returns the language tag as the String.
def to_s
  to_string
end

def to_str #:nodoc:

:nodoc:
def to_str  #:nodoc:
  to_s
end

def to_string

This is to use internal only. Use to_s instead.
Return simple language tag which format is"_".
def to_string  
  s = @language.dup
  s << "_" << @region if @region
  s      
end