module Censor class Base GARBLED_STRING = '$@!#%'.freeze REPLACEMENT_PATTERNS = { vowels: ->(str) { str.gsub(/[aeiou]/i, '*') }, stars: ->(str) { '*' * str.size }, nonconsonants: ->(word) { word.gsub(/[^bcdfghjklmnpqrstvwxyz]/i, '*') }, default: ->(_) { GARBLED_STRING } }.freeze class<= 3 censorship_source.each do |foul| return true if text =~ /\b#{foul}\b/i end false end end end end