Commit 8a45fd0f by Colin Rice

Adding support for incoming hash values.

parent f1d1cac7
...@@ -6,9 +6,9 @@ require 'stringio' ...@@ -6,9 +6,9 @@ require 'stringio'
module Rumoji module Rumoji
extend self extend self
# Transform emoji into its cheat-sheet code # Transform emoji into its cheat-sheet code (convert each entry to string first to handle hash values)
def encode(str) def encode(str)
str.gsub(Emoji::ALL_REGEXP) do |match| str.to_s.gsub(Emoji::ALL_REGEXP) do |match|
if emoji = Emoji.find_by_string(match) if emoji = Emoji.find_by_string(match)
if block_given? if block_given?
yield emoji yield emoji
...@@ -21,9 +21,9 @@ module Rumoji ...@@ -21,9 +21,9 @@ module Rumoji
end end
end end
# Transform a cheat-sheet code into an Emoji # Transform a cheat-sheet code into an Emoji (convert each entry to string first to handle hash values)
def decode(str) def decode(str)
str.gsub(/:([^\s:]?[\w-]+):/) { |match| (Emoji.find($1) || match).to_s } str.to_s.gsub(/:([^\s:]?[\w-]+):/) { |match| (Emoji.find($1) || match).to_s }
end end
def encode_io(readable, writeable=StringIO.new(""), &block) def encode_io(readable, writeable=StringIO.new(""), &block)
......
# New Emojis. Up to date with emoji-js.json as of 2/16/2018
# TODO: Recategorize emojis to the appropriate files.
require 'rumoji/emoji' require 'rumoji/emoji'
require 'set' require 'set'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment