Module: Pedantic::Punctuation

Included in:
Pedantic
Defined in:
lib/pedantic/punctuation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
# File 'lib/pedantic/punctuation.rb', line 2

def self.included(base)
  base.processors :replace_punctuation
end

Instance Method Details

#replace_punctuation(string) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pedantic/punctuation.rb', line 6

def replace_punctuation(string)
  {
    /\bcan't\b/ => 'cannot',
    /'/         => '',
    /sh\*t/     => 'shit',
    /f\*[\*c]k/ => 'fuck'
  }.each { |pattern, replacement|
    string.gsub!(pattern, replacement)
  }
  
  string
end