Module: Pedantic::Emoticons
- Included in:
- Pedantic
- Defined in:
- lib/pedantic/emoticons.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
2 3 4 |
# File 'lib/pedantic/emoticons.rb', line 2 def self.included(base) base.processors :replace_emoticons end |
Instance Method Details
#replace_emoticons(string) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pedantic/emoticons.rb', line 6 def replace_emoticons(string) { /(^|\s)\:\)(\s|$)/ => ' smile ', /(^|\s)\:\((\s|$)/ => ' sad ', /(^|\s)\:D(\s|$)/ => ' happy ', /(^|\s)\:S(\s|$)/ => ' unsure ', /(^|\s)\:s(\s|$)/ => ' unsure ', /(^|\s)\;\)(\s|$)/ => ' joke ' }.each do |pattern, replacement| string.gsub!(pattern, replacement) end string end |