Module: Inferno::Terminology::BCP47

Defined in:
lib/inferno/terminology/bcp47.rb

Constant Summary collapse

SEPARATOR =
'%%'.freeze
REGISTRY_URL =
'https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry'.freeze

Class Method Summary collapse

Class Method Details

.code_set(filter = nil) ⇒ Object



14
15
16
# File 'lib/inferno/terminology/bcp47.rb', line 14

def code_set(filter = nil)
  filter_codes(filter)
end

.filter_codes(filter = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/inferno/terminology/bcp47.rb', line 23

def filter_codes(filter = nil)
  bcp47 = bcp
  cs_set = Set.new
  bcp47.each do |raw_language|
    language = parse_language(raw_language)
    next if language['Subtag'].nil?
    next if language['Type'] == 'region'

    cs_set.add(system: 'urn:ietf:bcp:47', code: language['Subtag']) if meets_filter_criteria?(language, filter)
  end
  cs_set
end

.load_bcp47Object



18
19
20
21
# File 'lib/inferno/terminology/bcp47.rb', line 18

def load_bcp47
  response = RestClient.get REGISTRY_URL
  response.body.split(SEPARATOR).drop(1)
end