Commit 4914c7da by Colin Committed by GitHub

Merge pull request #2 from redtail-technology/develop

Develop
parents 7cb2cd9e 8a45fd0f
...@@ -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)
......
...@@ -61,8 +61,9 @@ module Rumoji ...@@ -61,8 +61,9 @@ module Rumoji
autoload :OBJECTS, 'rumoji/emoji/objects' autoload :OBJECTS, 'rumoji/emoji/objects'
autoload :PLACES, 'rumoji/emoji/places' autoload :PLACES, 'rumoji/emoji/places'
autoload :SYMBOLS, 'rumoji/emoji/symbols' autoload :SYMBOLS, 'rumoji/emoji/symbols'
autoload :NEWMOJI, 'rumoji/emoji/newmoji'
ALL = PEOPLE | NATURE | OBJECTS | PLACES | SYMBOLS | FOOD ALL = PEOPLE | NATURE | OBJECTS | PLACES | SYMBOLS | FOOD | NEWMOJI
ALL_REGEXP = Regexp.new(ALL.map(&:string).join('|')) ALL_REGEXP = Regexp.new(ALL.map(&:string).join('|'))
......
...@@ -73,7 +73,7 @@ module Rumoji ...@@ -73,7 +73,7 @@ module Rumoji
self.new("\u{1F959}", [:stuffed_flatbread]), self.new("\u{1F959}", [:stuffed_flatbread]),
self.new("\u{1F943}", [:tumbler_glass]), self.new("\u{1F943}", [:tumbler_glass]),
self.new("\u{1F942}", [:clinking_glasses]), self.new("\u{1F942}", [:clinking_glasses]),
self.new("\u{1F95B}", [:glass_of_milk]) self.new("\u{1F95B}", [:glass_of_milk]),
] ]
end end
end end
\ No newline at end of file
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