Method: String#emojify
- Defined in:
- lib/tdiary/core_ext.rb
#emojify ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tdiary/core_ext.rb', line 39 def emojify self.to_str.gsub(/:([a-zA-Z0-9_+-]+):/) do |match| emoji_alias = $1.downcase emoji_url = %Q[<img src='//www.webpagefx.com/tools/emoji-cheat-sheet/graphics/emojis/%s.png' width='20' height='20' title='%s' alt='%s' class='emoji' />] if emoji_alias == 'plus1' or emoji_alias == '+1' emoji_url % (['plus1']*3) elsif Emot.unicode(emoji_alias) emoji_url % ([CGI.escape(emoji_alias)]*3) else match end end end |