Class: Languages::Language
- Inherits:
-
Object
- Object
- Languages::Language
- Includes:
- Comparable
- Defined in:
- lib/languages/language.rb
Overview
Language defined in ISO 639-3
Instance Attribute Summary collapse
-
#iso639_1 ⇒ Object
(also: #alpha2)
readonly
, :comment.
-
#iso639_2b ⇒ Object
(also: #alpha3_bibliographic)
readonly
, :comment.
-
#iso639_2t ⇒ Object
(also: #iso639_2, #alpha3_terminology)
readonly
, :comment.
-
#iso639_3 ⇒ Object
(also: #alpha3)
readonly
, :comment.
-
#macrolanguage ⇒ Object
readonly
, :comment.
-
#name ⇒ Object
readonly
, :comment.
-
#scope ⇒ Object
readonly
, :comment.
-
#type ⇒ Object
readonly
, :comment.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(csv_attributes) ⇒ Language
constructor
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity.
- #to_s ⇒ Object
Constructor Details
#initialize(csv_attributes) ⇒ Language
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/languages/language.rb', line 10 def initialize(csv_attributes) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity @iso639_3 = csv_attributes.fetch(:id).to_sym @iso639_2b = csv_attributes.fetch(:part2b)&.to_sym @iso639_2t = csv_attributes.fetch(:part2t)&.to_sym @iso639_1 = csv_attributes.fetch(:part1)&.to_sym @scope = SCOPES.detect { |s| s.chr.upcase == csv_attributes.fetch(:scope) }&.to_sym @type = TYPES.detect { |t| t.chr.upcase == csv_attributes.fetch(:language_type) }&.to_sym @name = csv_attributes.fetch(:ref_name) # @comment = csv_attributes.fetch(:comment) end |
Instance Attribute Details
#iso639_1 ⇒ Object (readonly) Also known as: alpha2
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def iso639_1 @iso639_1 end |
#iso639_2b ⇒ Object (readonly) Also known as: alpha3_bibliographic
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def iso639_2b @iso639_2b end |
#iso639_2t ⇒ Object (readonly) Also known as: iso639_2, alpha3_terminology
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def iso639_2t @iso639_2t end |
#iso639_3 ⇒ Object (readonly) Also known as: alpha3
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def iso639_3 @iso639_3 end |
#macrolanguage ⇒ Object (readonly)
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def macrolanguage @macrolanguage end |
#name ⇒ Object (readonly)
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def name @name end |
#scope ⇒ Object (readonly)
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def scope @scope end |
#type ⇒ Object (readonly)
, :comment
8 9 10 |
# File 'lib/languages/language.rb', line 8 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
58 59 60 |
# File 'lib/languages/language.rb', line 58 def <=>(other) other.iso639_3 <=> iso639_3 end |
#==(other) ⇒ Object Also known as: eql?
48 49 50 |
# File 'lib/languages/language.rb', line 48 def ==(other) other.class == self.class && other.iso639_3 == iso639_3 end |
#hash ⇒ Object
54 55 56 |
# File 'lib/languages/language.rb', line 54 def hash iso639_3.hash end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/languages/language.rb', line 29 def to_s name.to_s # Enforce return of String, even if name is nil end |