Commit 9178177e by Mark Wunsch

Better variable names

parent 7dbea734
...@@ -21,25 +21,25 @@ module Rumoji ...@@ -21,25 +21,25 @@ module Rumoji
duplicate duplicate
end end
def encode_io(input, output=StringIO.new("")) def encode_io(readable, writeable=StringIO.new(""))
input.each_codepoint do |codepoint| readable.each_codepoint do |codepoint|
emoji = codepoint.to_s(16).upcase emoji = codepoint.to_s(16).upcase
emoji_or_character = EMOJI_NAME_TO_CODEPOINT.has_value?(emoji) ? ":#{EMOJI_NAME_TO_CODEPOINT.key(emoji)}:" : [codepoint].pack("U") emoji_or_character = EMOJI_NAME_TO_CODEPOINT.has_value?(emoji) ? ":#{EMOJI_NAME_TO_CODEPOINT.key(emoji)}:" : [codepoint].pack("U")
output.write emoji_or_character writeable.write emoji_or_character
end end
output.rewind writeable.rewind
output writeable
end end
def decode_io(input, output=StringIO.new("")) def decode_io(readable, writeable=StringIO.new(""))
input.each do |word| readable.each do |word|
EMOJI_NAME_TO_CODEPOINT.each_pair do |key,value| EMOJI_NAME_TO_CODEPOINT.each_pair do |key,value|
word.gsub!(":#{key}:", [value.to_i(16)].pack("U")) word.gsub!(":#{key}:", [value.to_i(16)].pack("U"))
end end
output.write(word) writeable.write(word)
end end
output.rewind writeable.rewind
output writeable
end end
EMOJI_NAME_TO_CODEPOINT = { EMOJI_NAME_TO_CODEPOINT = {
......
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