module Emojimmy
Constants
- VERSION
Public Class Methods
emoji_to_token(content)
click to toggle source
Loop through all emoji and replace them with their matching token
# File lib/emojimmy.rb, line 15 def self.emoji_to_token(content) return content unless content.present? # Encode the string with Rumoji content = Rumoji.encode(content) # Return the text without any other weird characters Emojimmy.strip(content) end
strip(content)
click to toggle source
Loop through each character in the string and remove the all emoji ones
# File lib/emojimmy.rb, line 35 def self.strip(content) return content unless content.present? content.chars.select do |c| point = c.each_codepoint.to_a.first point <= 65535 end.join end
token_to_emoji(content)
click to toggle source
Loop through each {U+…} token in the string and convert it to the matching emoji
# File lib/emojimmy.rb, line 27 def self.token_to_emoji(content) return content unless content.present? Rumoji.decode(content) end