Sha256: 55eea44e1440c850dc6b52d7da4499be5e1925e1b89105ab58b5e6d4749c1b6e
Contents?: true
Size: 976 Bytes
Versions: 2
Compression:
Stored size: 976 Bytes
Contents
# encoding: utf-8 require 'emojimmy/version' # Dependencies require 'rumoji' require 'active_record' # Modules require 'emojimmy/mixin' require 'emojimmy/extensions' module Emojimmy # Loop through all emoji and replace them with # their matching token 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 # Loop through each {U+...} token in the string and # convert it to the matching emoji def self.token_to_emoji(content) return content unless content.present? Rumoji.decode(content) end # Loop through each character in the string and # remove the all emoji ones 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
emojimmy-0.3 | lib/emojimmy.rb |
emojimmy-0.2.2 | lib/emojimmy.rb |