Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/bad_word_detector/whitelist.rb

Instance Method Summary collapse

Instance Method Details

#get_substring_words(index, length) ⇒ Object



32
33
34
35
36
# File 'lib/bad_word_detector/whitelist.rb', line 32

def get_substring_words(index, length)
  word_begin = self.rindex(' ', index) || -1
  word_end = self.index(' ', (index + length)) || self.length
  self[word_begin+1..word_end-1].split(/[[:punct:]\s]+/)
end