Sha256: 6f5f2eba6737591c7b52697e2066c284c4976c738f50a063a4ed32b69f720108

Contents?: true

Size: 610 Bytes

Versions: 41

Compression:

Stored size: 610 Bytes

Contents

module Inferno
  module Terminology
    module BCP13
      @code_set = nil

      def self.code_set
        @code_set ||= parse_code_set
      end

      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" step for BCP13 codes, to remove any of the optional parameters
      # and downcase them
      def self.preprocess_code(code)
        code&.split(';')&.first&.downcase
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
onc_certification_g10_test_kit-2.0.0.rc1 lib/inferno/terminology/bcp_13.rb