Sha256: 3f314c84866589908e7b0c06a8ec20bc3142f197f7216dbe1fddfb63c7e57f81

Contents?: true

Size: 483 Bytes

Versions: 2

Compression:

Stored size: 483 Bytes

Contents

module Pedantic::Emoticons
  def self.included(base)
    base.processors :replace_emoticons
  end
  
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pedantic-0.1.1 lib/pedantic/emoticons.rb
pedantic-0.1.0 lib/pedantic/emoticons.rb