Class: NaughtyWords::Base
- Inherits:
-
Object
- Object
- NaughtyWords::Base
- Defined in:
- lib/naughty_words/base.rb
Class Method Summary collapse
- .add_to_list(list:, string:) ⇒ Object
- .filter(string:, replacement:) ⇒ Object
- .profanity?(string:) ⇒ Boolean
- .show_list(list:) ⇒ Object
Class Method Details
.add_to_list(list:, string:) ⇒ Object
27 28 29 30 31 |
# File 'lib/naughty_words/base.rb', line 27 def add_to_list(list:, string:) File.open(send(list), "a+") do |file| file.puts(string) end end |
.filter(string:, replacement:) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/naughty_words/base.rb', line 18 def filter(string:, replacement:) deny_list_array.each do |line| word = line string.gsub!(word, replacement * word.length) end string end |
.profanity?(string:) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/naughty_words/base.rb', line 6 def profanity?(string:) allow_list_array.each do |line| return false if string.include?(line) end deny_list_array.each do |line| return true if string.include?(line) end false end |
.show_list(list:) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/naughty_words/base.rb', line 33 def show_list(list:) if list == "deny" deny_list_array else allow_list_array end end |