class PrettyProfanity::Word
Attributes
whitelist[RW]
word[RW]
Public Class Methods
new(word)
click to toggle source
# File src/pretty-profanity/word.rb, line 7 def initialize(word) @word = word @whitelist = Profanity.whitelist end
Public Instance Methods
after_regex()
click to toggle source
# File src/pretty-profanity/word.rb, line 21 def after_regex words = whitelist(/#{word}$/) "(?<!#{words.join('|')})" unless words.empty? end
before_regex()
click to toggle source
# File src/pretty-profanity/word.rb, line 16 def before_regex words = whitelist(/^#{word}/) "(?!#{words.join('|')})" unless words.empty? end
to_regex()
click to toggle source
# File src/pretty-profanity/word.rb, line 12 def to_regex /#{before_regex}\b(#{word})\b#{after_regex}/i end