Module: Iev::DataSource
- Defined in:
- lib/iev/data_source.rb
Defined Under Namespace
Classes: NotFoundError
Class Method Summary collapse
-
.fetch_concept(code) ⇒ Hash?
Fetch full concept data (all languages) for a given IEV code.
-
.fetch_term(code, lang) ⇒ Hash?
Fetch localized term data for a given IEV code and language.
-
.fetch_term_designation(code, lang) ⇒ String?
Fetch the term designation string for a given IEV code and language.
Class Method Details
.fetch_concept(code) ⇒ Hash?
Fetch full concept data (all languages) for a given IEV code.
16 17 18 |
# File 'lib/iev/data_source.rb', line 16 def fetch_concept(code) fetch_concept_data(code) end |
.fetch_term(code, lang) ⇒ Hash?
Fetch localized term data for a given IEV code and language.
25 26 27 28 29 30 31 |
# File 'lib/iev/data_source.rb', line 25 def fetch_term(code, lang) concept = fetch_concept(code) return nil unless concept lang_key = normalize_lang(lang) concept[lang_key] end |
.fetch_term_designation(code, lang) ⇒ String?
Fetch the term designation string for a given IEV code and language. This is the backward-compatible replacement for the scraping-based Iev.get.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/iev/data_source.rb', line 39 def fetch_term_designation(code, lang) term_data = fetch_term(code, lang) return nil unless term_data terms = term_data["terms"] return nil unless terms&.any? preferred = terms.find { |t| t["normative_status"] == "preferred" } (preferred || terms.first)["designation"] end |