lib/iso-639.rb in iso-639-0.2.8 vs lib/iso-639.rb in iso-639-0.2.9
- old
+ new
@@ -1,7 +1,7 @@
-# encoding: UTF-8
# frozen_string_literal: true
+
# http://www.loc.gov/standards/iso639-2/ascii_8bits.html
class ISO_639 < Array
# Redefine `[]` to freeze all strings and arrays.
#
@@ -551,13 +551,14 @@
class << self
# Returns the entry array for an alpha-2 or alpha-3 code
def find_by_code(code)
return if code.nil?
+
case code.length
when 3
ISO_639_2.detect do |entry|
- entry if entry.alpha3 == code || entry.alpha3_terminologic == code
+ entry if [entry.alpha3, entry.alpha3_terminologic].include?(code)
end
when 2
ISO_639_1.detect do |entry|
entry if entry.alpha2 == code
end