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_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_3(code) ⇒ Object
- .find_by_name(name) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #common? ⇒ Boolean
-
#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 |
# File 'lib/language_list.rb', line 7 def initialize() @name = [:name] @iso_639_3 = [:iso_639_3] @iso_639_1 = [:iso_639_1] @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_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
49 50 51 |
# File 'lib/language_list.rb', line 49 def self.find(code) find_by_iso_639_1(code) || find_by_iso_639_3(code) || find_by_name(code) end |
.find_by_iso_639_1(code) ⇒ Object
37 38 39 |
# File 'lib/language_list.rb', line 37 def self.find_by_iso_639_1(code) LanguageList::BY_ISO_639_1[code] end |
.find_by_iso_639_3(code) ⇒ Object
41 42 43 |
# File 'lib/language_list.rb', line 41 def self.find_by_iso_639_3(code) LanguageList::BY_ISO_639_3[code] end |
.find_by_name(name) ⇒ Object
45 46 47 |
# File 'lib/language_list.rb', line 45 def self.find_by_name(name) LanguageList::BY_NAME[name] end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 |
# File 'lib/language_list.rb', line 19 def <=>(other) self.name <=> other.name end |
#common? ⇒ Boolean
15 16 17 |
# File 'lib/language_list.rb', line 15 def common? @common end |
#iso_639_1? ⇒ Boolean
23 24 25 |
# File 'lib/language_list.rb', line 23 def iso_639_1? !@iso_639_1.nil? end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/language_list.rb', line 33 def to_s "#{@iso_639_3}#{" (#{@iso_639_1})" if @iso_639_1} - #{@name}" end |