Module: Inferno::Terminology::BCP13

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

Class Method Summary collapse

Class Method Details

.code_setObject



6
7
8
# File 'lib/inferno/terminology/bcp_13.rb', line 6

def self.code_set
  @code_set ||= parse_code_set
end

.parse_code_setObject



10
11
12
13
14
15
16
17
# File 'lib/inferno/terminology/bcp_13.rb', line 10

def self.parse_code_set
  require 'mime/types'
  cs_set = Set.new
  MIME::Types.each do |type|
    cs_set.add(system: 'urn:ietf:bcp:13', code: preprocess_code(type.simplified))
  end
  cs_set
end

.preprocess_code(code) ⇒ Object

“preprocess” step for BCP13 codes, to remove any of the optional parameters and downcase them



21
22
23
# File 'lib/inferno/terminology/bcp_13.rb', line 21

def self.preprocess_code(code)
  code&.split(';')&.first&.downcase
end