Module: Pedantic::Txt

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#replace_txt_words(string) ⇒ Object



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

def replace_txt_words(string)
  {
    /\btn?x\b/i  => 'thanks',
    /\bthnks\b/i => 'thanks'
  }.each { |pattern, replacement|
    string.gsub!(pattern, replacement)
  }
  
  string
end