Class: Moderate::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/moderate/text.rb

Class Method Summary collapse

Class Method Details

.bad_words?(text) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'lib/moderate/text.rb', line 6

def bad_words?(text)
  return false if text.blank?

  @words_set ||= Set.new(compute_word_list)
  text.downcase.split(/\W+/).any? { |word| @words_set.include?(word) }
end