def replace_code(string, &block)
      string.gsub(code_pattern) do |matched_string|
        block.call(find_by_code(::Regexp.last_match(1)), matched_string)
      end
    end
def replace_code(string, &block)
      string.gsub(code_pattern) do |matched_string|
        block.call(find_by_code(::Regexp.last_match(1)), matched_string)
      end
    end
Replaces emoji codes in a given string with a given block result
 @param string [String] a string that to be replaced
 @return [String] a replaced result
 @example
   Somemoji.emoji_collection.replace_code("I :heart: Emoji") do |emoji|
     %(<img alt="#{emoji.character}" class="emoji" src="/images/emoji/#{emoji.base_path}.png">)
   end
   #=> 'I <img alt="❤" class="emoji" src="/images/emoji/unicode/2764.png"> Emoji'