Class: Locale::Info::Language
- Inherits:
-
Object
- Object
- Locale::Info::Language
- Defined in:
- lib/locale/info/language.rb
Overview
This class contains all the of the ISO information for the ISO 639-3 languages. This class is immutable once constructed.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#three_code ⇒ Object
readonly
Returns the value of attribute three_code.
-
#two_code ⇒ Object
readonly
Returns the value of attribute two_code.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#ancient? ⇒ Boolean
Returns true if the language is an ancient language according to the ISO 639-3 data.
-
#constructed? ⇒ Boolean
Returns true if the language is a constructed language according to the ISO 639-3 data.
-
#extinct? ⇒ Boolean
Returns true if the language is an extinct language according to the ISO 639-3 data.
-
#historical? ⇒ Boolean
Returns true if the language is an historical language according to the ISO 639-3 data.
-
#individual? ⇒ Boolean
Returns true if the language is an individual language according to the ISO 639-3 data.
-
#initialize(two_code, three_code, scope, type, name) ⇒ Language
constructor
Constructs a new Language instance.
-
#iso_language? ⇒ Boolean
Returns this object is valid as ISO 639 data.
-
#living? ⇒ Boolean
Returns true if the language is a living language according to the ISO 639-3 data.
-
#macro? ⇒ Boolean
Returns true if the language is a macro language according to the ISO 639-3 data.
-
#special? ⇒ Boolean
Returns true if the language is a special language according to the ISO 639-3 data.
-
#special_type? ⇒ Boolean
Returns true if the language is a special type language according to the ISO 639-3 data.
-
#to_s ⇒ Object
Returns the two or three code.
Constructor Details
#initialize(two_code, three_code, scope, type, name) ⇒ Language
Constructs a new Language instance.
-
code The 2 or 3 digit ISO 639-3 language code.
-
scope A single character that defines the ISO scope of the language -
(I)ndividual
,(M)acrolanguage
, or(S)pecial
. -
type A single character that defines the ISO type of the language -
(A)ncient
,(C)onstructed
,(E)xtinct
,(H)istorical
,(L)iving
, or(S)pecial
. -
name The name of the language.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/locale/info/language.rb', line 34 def initialize(two_code, three_code, scope, type, name) @two_code, @three_code, @scope, @type, @name = two_code, three_code, scope, type, name @individual = (scope == "I") @macro = (scope == "M") @special = (scope == "S") @constructed = (type == "C") @living = (type == "L") @extinct = (type == "E") @ancient = (type == "A") @historical = (type == "H") @special_type = (type == "S") end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/locale/info/language.rb', line 21 def name @name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
21 22 23 |
# File 'lib/locale/info/language.rb', line 21 def scope @scope end |
#three_code ⇒ Object (readonly)
Returns the value of attribute three_code.
21 22 23 |
# File 'lib/locale/info/language.rb', line 21 def three_code @three_code end |
#two_code ⇒ Object (readonly)
Returns the value of attribute two_code.
21 22 23 |
# File 'lib/locale/info/language.rb', line 21 def two_code @two_code end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/locale/info/language.rb', line 21 def type @type end |
Instance Method Details
#ancient? ⇒ Boolean
Returns true if the language is an ancient language according to the ISO 639-3 data.
67 |
# File 'lib/locale/info/language.rb', line 67 def ancient?; @ancient; end |
#constructed? ⇒ Boolean
Returns true if the language is a constructed language according to the ISO 639-3 data.
58 |
# File 'lib/locale/info/language.rb', line 58 def constructed?; @constructed; end |
#extinct? ⇒ Boolean
Returns true if the language is an extinct language according to the ISO 639-3 data.
64 |
# File 'lib/locale/info/language.rb', line 64 def extinct?; @extinct; end |
#historical? ⇒ Boolean
Returns true if the language is an historical language according to the ISO 639-3 data.
70 |
# File 'lib/locale/info/language.rb', line 70 def historical?; @historical; end |
#individual? ⇒ Boolean
Returns true if the language is an individual language according to the ISO 639-3 data.
49 |
# File 'lib/locale/info/language.rb', line 49 def individual?; @individual; end |
#iso_language? ⇒ Boolean
Returns this object is valid as ISO 639 data.
85 86 87 |
# File 'lib/locale/info/language.rb', line 85 def iso_language? @@lang_two_codes[two_code] != nil || @@lang_three_codes[three_code] != nil end |
#living? ⇒ Boolean
Returns true if the language is a living language according to the ISO 639-3 data.
61 |
# File 'lib/locale/info/language.rb', line 61 def living?; @living; end |
#macro? ⇒ Boolean
Returns true if the language is a macro language according to the ISO 639-3 data.
52 |
# File 'lib/locale/info/language.rb', line 52 def macro?; @macro; end |
#special? ⇒ Boolean
Returns true if the language is a special language according to the ISO 639-3 data.
55 |
# File 'lib/locale/info/language.rb', line 55 def special?; @special; end |
#special_type? ⇒ Boolean
Returns true if the language is a special type language according to the ISO 639-3 data.
73 |
# File 'lib/locale/info/language.rb', line 73 def special_type?; @special_type; end |
#to_s ⇒ Object
Returns the two or three code.
76 77 78 79 80 81 82 |
# File 'lib/locale/info/language.rb', line 76 def to_s if two_code and two_code.size > 0 two_code else three_code end end |