Commit 9178177e by Mark Wunsch

Better variable names

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