Module: Edoxen::ReferenceData
- Defined in:
- lib/edoxen/reference_data.rb,
sig/edoxen.rbs
Overview
Built-in reference data for ISO codes used across the Edoxen model: ISO 3166-1 alpha-2 country codes, ISO 639-3 language codes, ISO 15924 script codes, UN/LOCODEs, and IATA airport codes.
UN/LOCODE lookups delegate to the unlocodes gem (the canonical
Ruby registry of the UNECE UN/LOCODE dataset).
IATA lookups delegate to the iata gem (the canonical Ruby registry
of the IATA airport code list, sourced from Wikidata).
Reference data sources:
Constant Summary collapse
- COUNTRY_CODES =
%w[ AE AF AR AT AU BE BG BR BY CA CH CL CN CO CY CZ DE DK EE ES FI FR GB GR HK HR HU ID IE IL IN IS IT JP KE KR LK LT LU LV MT MX MY NL NO PH NZ PL PT RO RS RU SA SE SG SI SK TH TN TR TW UA US VN ZA ].freeze
- LANGUAGE_CODES =
%w[ ara chi deu eng fra jpn rus spa zho ].freeze
- SCRIPT_CODES =
%w[ Arab Cyrl Hans Hant Hang Hebr Jpan Kore Latn ].freeze
- UNLOCODES =
%w[ AUMEL ATVIE BEBRU BGSOF BRBSB CHGVA CNCAN CNHKG CNSHA CNXSZ COCTG CYLCA CZPRG DEBER DEHAM DEFRA DKCPH ESMAD FIHEL FRARC FRLYS FRMRS FRPAR GBLON HKHKG HUBUD IDJKT IEDUB IEORK ILTLV INDEL ISREY ITROM JPTYO KEMBA KRSEL LKCMB LVRIX LULUX MYKUL NLRTM NOOSL NZAKL PHMNL PLWAW PTLIS ROBUH RSBEG SESTO SGSIN SKBTS THBKK THCNM TRIST TWTPE UAIEV USMIA USNYC USORL VNSGN ZACPT ].freeze
Class Method Summary collapse
-
.find_iata(code) ⇒ Iata::Entry?
Look up an IATA airport/city code via the canonical
iatagem. -
.find_unlocode(code) ⇒ Unlocodes::Entry?
Look up a UN/LOCODE entry via the canonical
unlocodesgem. - .iata_exists?(code) ⇒ Boolean
- .iata_registry ⇒ Iata::Registry
- .unlocode_exists?(code) ⇒ Boolean
- .unlocodes_registry ⇒ Unlocodes::Registry
Class Method Details
.find_iata(code) ⇒ Iata::Entry?
Look up an IATA airport/city code via the canonical iata gem.
76 77 78 |
# File 'lib/edoxen/reference_data.rb', line 76 def find_iata(code) iata_registry.find(code.to_s.upcase) end |
.find_unlocode(code) ⇒ Unlocodes::Entry?
Look up a UN/LOCODE entry via the canonical unlocodes gem.
65 66 67 |
# File 'lib/edoxen/reference_data.rb', line 65 def find_unlocode(code) unlocodes_registry.find(code.to_s.upcase) end |
.iata_exists?(code) ⇒ Boolean
80 81 82 |
# File 'lib/edoxen/reference_data.rb', line 80 def iata_exists?(code) !find_iata(code).nil? end |
.iata_registry ⇒ Iata::Registry
58 59 60 |
# File 'lib/edoxen/reference_data.rb', line 58 def iata_registry @iata_registry ||= Iata::Registry.load_default end |
.unlocode_exists?(code) ⇒ Boolean
69 70 71 |
# File 'lib/edoxen/reference_data.rb', line 69 def unlocode_exists?(code) !find_unlocode(code).nil? end |
.unlocodes_registry ⇒ Unlocodes::Registry
53 54 55 |
# File 'lib/edoxen/reference_data.rb', line 53 def unlocodes_registry @unlocodes_registry ||= Unlocodes::Registry.load_default end |