module Emoju
Constants
- SUPPORTED_ENCODINGS
- VERSION
Public Instance Methods
docomo_to_unicode(str)
click to toggle source
# File lib/emoju.rb, line 19 def docomo_to_unicode(str) convert_from(str, :docomo) end
google_to_unicode(str)
click to toggle source
# File lib/emoju.rb, line 23 def google_to_unicode(str) convert_from(str, :google) end
softbank_to_unicode(str)
click to toggle source
# File lib/emoju.rb, line 15 def softbank_to_unicode(str) convert_from(str, :softbank) end
unify(str)
click to toggle source
# File lib/emoju.rb, line 9 def unify(str) result = softbank_to_unicode(str) result = google_to_unicode(result) docomo_to_unicode(result) end
Private Instance Methods
codpoint_to_str(codepoint)
click to toggle source
# File lib/emoju.rb, line 48 def codpoint_to_str(codepoint) codepoint.split("-").map { |c| [c.hex].pack("U") }.join end
convert_from(str, encoding)
click to toggle source
# File lib/emoju.rb, line 33 def convert_from(str, encoding) if SUPPORTED_ENCODINGS.include?(encoding) regexp = emoji_data.regexp_for(encoding) codepoint_map = emoji_data.public_send("emoji_#{encoding}_map".to_sym) str.gsub(regexp) do |capture| codepoint = capture.codepoints.map { |i| i.to_s(16).rjust(4,'0')}.join('-').upcase unified_codepoint = codepoint_map[codepoint] codpoint_to_str(unified_codepoint) end else fail "unsupported encoding" end end
emoji_data()
click to toggle source
# File lib/emoju.rb, line 29 def emoji_data @emoji_data ||= Data.new() end