Class: BadwordTracker
- Inherits:
-
Object
- Object
- BadwordTracker
- Defined in:
- lib/badword_tracker.rb
Instance Method Summary collapse
-
#change_to_star(arr) ⇒ Object
[“ass”, “fuck”, “bitcher”, “cawk”].
-
#find_same_badword(input, arr_2) ⇒ Object
[“it”, “is”, “ass”].
- #init ⇒ Object
- #send_review_text(review_text) ⇒ Object
Instance Method Details
#change_to_star(arr) ⇒ Object
- “ass”, “fuck”, “bitcher”, “cawk”
27 28 29 30 31 32 33 34 |
# File 'lib/badword_tracker.rb', line 27 def change_to_star(arr) #["ass", "fuck", "bitcher", "cawk"] output = [] arr.each do |badword| cw= badword.gsub(/[aeiou]/, "*") output << cw end output end |
#find_same_badword(input, arr_2) ⇒ Object
- “it”, “is”, “ass”
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/badword_tracker.rb', line 15 def find_same_badword(input, arr_2) #["it", "is", "ass"] output = [] input.each do |word| arr_2.each do |s| if (word.eql?(s)) output << word end end end output end |
#init ⇒ Object
4 5 6 7 |
# File 'lib/badword_tracker.rb', line 4 def init @matchfile =File.foreach(File.dirname(__FILE__) + '/badword.txt').map {|line| line.chomp } @matchfile #["idiot", "4r5e"...] end |
#send_review_text(review_text) ⇒ Object
9 10 11 12 13 |
# File 'lib/badword_tracker.rb', line 9 def send_review_text(review_text) @downcase=review_text.downcase words_arr = @downcase.split(/(?:\s+|-)/) words_arr #=@words = ["it", "is", "ass"] end |