module EmojiFlag
Constants
- COUNTRY_CODE_RE
- DEFAULTS
Thankfully taken from: github.com/10xjs/locale-emoji
- OFFSET
- VERSION
Public Class Methods
code_for_locale(locale)
click to toggle source
# File lib/emoji_flag.rb, line 18 def self.code_for_locale(locale) split = locale.upcase.split(/-|_/) lang = split.shift code = split.pop code = DEFAULTS[lang.downcase.to_sym] unless COUNTRY_CODE_RE.match(code) code || '' end
new(input)
click to toggle source
# File lib/emoji_flag.rb, line 9 def self.new(input) locale = input.to_s return '' if locale.nil? || locale.size.zero? code = code_for_locale(locale) code.codepoints.collect { |codepoint| codepoint + OFFSET }.pack('U*') end