Sha256: 7400e4d061768f4725cd289328224240339e0d103b30e50ab250f8932675e5ed

Contents?: true

Size: 717 Bytes

Versions: 7

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

module Sources
  module CLDR
    # Auxiliary Subdivision class to support loading Unicode CLDR data to update local files
    class Subdivision
      attr_reader :xml, :language_code

      def initialize(language_code:, xml:)
        @language_code = language_code
        @xml = xml
      end

      def text
        xml.text
      end

      def country_code
        type[0..1].upcase
      end

      def code
        type[2..].upcase
      end

      def type
        xml.attributes['type'].value.delete('-')
      end

      def to_h
        data = {}
        data['translations'] ||= {}
        data['translations'][language_code] = text
        data
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
countries-7.0.0 lib/countries/sources/cldr/subdivision.rb
countries-6.0.0 lib/countries/sources/cldr/subdivision.rb
countries-5.7.2 lib/countries/sources/cldr/subdivision.rb
countries-5.7.1 lib/countries/sources/cldr/subdivision.rb
countries-5.7.0 lib/countries/sources/cldr/subdivision.rb
countries-5.6.0 lib/countries/sources/cldr/subdivision.rb
countries-5.5.0 lib/countries/sources/cldr/subdivision.rb