Class: LanguageList::LanguageInfo
- Inherits:
-
Object
- Object
- LanguageList::LanguageInfo
- Defined in:
- lib/language_list.rb
Instance Attribute Summary collapse
-
#iso_639_1 ⇒ Object
readonly
Returns the value of attribute iso_639_1.
-
#iso_639_2b ⇒ Object
readonly
Returns the value of attribute iso_639_2b.
-
#iso_639_2t ⇒ Object
readonly
Returns the value of attribute iso_639_2t.
-
#iso_639_3 ⇒ Object
readonly
Returns the value of attribute iso_639_3.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .find(code) ⇒ Object
- .find_by_iso_639_1(code) ⇒ Object
- .find_by_iso_639_2b(code) ⇒ Object
- .find_by_iso_639_2t(code) ⇒ Object
- .find_by_iso_639_3(code) ⇒ Object
- .find_by_name(name) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #common? ⇒ Boolean
- #common_name ⇒ Object
-
#initialize(options) ⇒ LanguageInfo
constructor
A new instance of LanguageInfo.
- #iso_639_1? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(options) ⇒ LanguageInfo
Returns a new instance of LanguageInfo.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/language_list.rb', line 7 def initialize() @name = [:name] @common_name = [:common_name] @iso_639_3 = [:iso_639_3] @iso_639_1 = [:iso_639_1] @iso_639_2b = [:iso_639_2b] @iso_639_2t = [:iso_639_2t] @common = [:common] @type = [:type] end |
Instance Attribute Details
#iso_639_1 ⇒ Object (readonly)
Returns the value of attribute iso_639_1.
5 6 7 |
# File 'lib/language_list.rb', line 5 def iso_639_1 @iso_639_1 end |
#iso_639_2b ⇒ Object (readonly)
Returns the value of attribute iso_639_2b.
5 6 7 |
# File 'lib/language_list.rb', line 5 def iso_639_2b @iso_639_2b end |
#iso_639_2t ⇒ Object (readonly)
Returns the value of attribute iso_639_2t.
5 6 7 |
# File 'lib/language_list.rb', line 5 def iso_639_2t @iso_639_2t end |
#iso_639_3 ⇒ Object (readonly)
Returns the value of attribute iso_639_3.
5 6 7 |
# File 'lib/language_list.rb', line 5 def iso_639_3 @iso_639_3 end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/language_list.rb', line 5 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/language_list.rb', line 5 def type @type end |
Class Method Details
.find(code) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/language_list.rb', line 66 def self.find(code) return if code.nil? code = code.downcase find_by_iso_639_1(code) || find_by_iso_639_3(code) || find_by_iso_639_2b(code) || find_by_iso_639_2t(code) || find_by_name(code) end |
.find_by_iso_639_1(code) ⇒ Object
44 45 46 |
# File 'lib/language_list.rb', line 44 def self.find_by_iso_639_1(code) LanguageList::BY_ISO_639_1[code] end |
.find_by_iso_639_2b(code) ⇒ Object
52 53 54 |
# File 'lib/language_list.rb', line 52 def self.find_by_iso_639_2b(code) LanguageList::BY_ISO_639_2B[code] end |
.find_by_iso_639_2t(code) ⇒ Object
56 57 58 |
# File 'lib/language_list.rb', line 56 def self.find_by_iso_639_2t(code) LanguageList::BY_ISO_639_2T[code] end |
.find_by_iso_639_3(code) ⇒ Object
48 49 50 |
# File 'lib/language_list.rb', line 48 def self.find_by_iso_639_3(code) LanguageList::BY_ISO_639_3[code] end |
.find_by_name(name) ⇒ Object
60 61 62 63 64 |
# File 'lib/language_list.rb', line 60 def self.find_by_name(name) return if name.nil? LanguageList::BY_NAME[name.downcase] end |
Instance Method Details
#<=>(other) ⇒ Object
26 27 28 |
# File 'lib/language_list.rb', line 26 def <=>(other) self.name <=> other.name end |
#common? ⇒ Boolean
22 23 24 |
# File 'lib/language_list.rb', line 22 def common? @common end |
#common_name ⇒ Object
18 19 20 |
# File 'lib/language_list.rb', line 18 def common_name @common_name || @name end |
#iso_639_1? ⇒ Boolean
30 31 32 |
# File 'lib/language_list.rb', line 30 def iso_639_1? !@iso_639_1.nil? end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/language_list.rb', line 40 def to_s "#{@iso_639_3}#{" (#{@iso_639_1})" if @iso_639_1} - #{@name}" end |