class PrettyProfanity::Profanity
Attributes
blacklist[RW]
replacement[RW]
whitelist[RW]
Public Class Methods
configure() { |self| ... }
click to toggle source
# File src/pretty-profanity/profanity.rb, line 9 def configure yield(self) end
offensive(text)
click to toggle source
# File src/pretty-profanity/profanity.rb, line 29 def offensive(text) text = text.to_s blacklist.select do |word| true if text.match(Word.new(word).to_regex) end end
profane?(text)
click to toggle source
# File src/pretty-profanity/profanity.rb, line 13 def profane?(text) text = text.to_s !!blacklist.detect do |word| true if text.match(Word.new(word).to_regex) end end
sanitize(text)
click to toggle source
# File src/pretty-profanity/profanity.rb, line 20 def sanitize(text) text = text.to_s cleanse = Sanitize.new blacklist.each do |word| text.gsub!(Word.new(word).to_regex, cleanse.send(replacement, word)) end text end