Sha256: 3456b123a3ab892d948b8254ffc719ead03b7bc27ed4c7c418a71be002c8c48d

Contents?: true

Size: 993 Bytes

Versions: 9

Compression:

Stored size: 993 Bytes

Contents

# encoding: utf-8
module Zebra
  module Zpl
    class CountryCode
      class InvalidCountryCodeError < StandardError; end

      BELGIUM       = "032"
      CANADA        = "002"
      DENMARK       = "045"
      FINLAND       = "358"
      FRANCE        = "033"
      GERMANY       = "049"
      NETHERLANDS   = "031"
      ITALY         = "039"
      LATIN_AMERICA = "003"
      NORWAY        = "047"
      PORTUGAL      = "351"
      SOUTH_AFRICA  = "027"
      SPAIN         = "034"
      SWEDEN        = "046"
      SWITZERLAND   = "041"
      UK            = "044"
      USA           = "001"

      def self.valid_country_code?(code)
        [BELGIUM, CANADA, DENMARK, FINLAND, FRANCE, GERMANY, NETHERLANDS,
         ITALY, LATIN_AMERICA, NORWAY, PORTUGAL, SOUTH_AFRICA, SPAIN, SWEDEN, SWITZERLAND,
         UK, USA].include?(code)
      end

      def self.validate_country_code(code)
        raise InvalidCountryCodeError unless valid_country_code?(code)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zebra-zpl-1.1.4 lib/zebra/zpl/country_code.rb
zebra-zpl-1.1.3 lib/zebra/zpl/country_code.rb
zebra-zpl-1.1.2 lib/zebra/zpl/country_code.rb
zebra-zpl-1.1.1 lib/zebra/zpl/country_code.rb
zebra-zpl-1.1.0 lib/zebra/zpl/country_code.rb
zebra-zpl-1.0.5 lib/zebra/zpl/country_code.rb
zebra-zpl-1.0.2 lib/zebra/zpl/country_code.rb
zebra-zpl-1.0.1 lib/zebra/zpl/country_code.rb
zebra-zpl-1.0.0 lib/zebra/zpl/country_code.rb