Sha256: 97e534a4740009c4cd3e1c6622fc4d3f7cebd4225b4a18282cb52ef1406d65f0

Contents?: true

Size: 357 Bytes

Versions: 2

Compression:

Stored size: 357 Bytes

Contents

module UnicodeCountryFlags
  module CountryFlags
    class << self
      def flag_of(code)
        code = code.to_s.downcase
        return unless code.size == 2
        code.chars.map { |c| unicodes[c] }.join("")
      end

      def unicodes
        @unicodes ||= Hash[ ('a'..'z').zip (0x1F1E6..0x1F1FF).map { |i| "&##{i};"} ]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unicode_country_flags-0.1.1 lib/unicode_country_flags/country_flags.rb
unicode_country_flags-0.1.0 lib/unicode_country_flags/country_flags.rb