Class: DespamilatorFilter::NoVowels

Inherits:
Despamilator::Filter show all
Defined in:
lib/despamilator/filter/no_vowels.rb

Constant Summary collapse

NO_VOWELS_REGEX =
/^[b-df-hj-np-tv-xzB-DF-HJ-NP-TV-XZ]+$/

Instance Method Summary collapse

Instance Method Details

#descriptionObject



13
14
15
# File 'lib/despamilator/filter/no_vowels.rb', line 13

def description
  'Detects things that are all letters but no vowels and separated by spaces'
end

#nameObject



9
10
11
# File 'lib/despamilator/filter/no_vowels.rb', line 9

def name
  'No Vowels'
end

#parse(subject) ⇒ Object



17
18
19
20
21
22
# File 'lib/despamilator/filter/no_vowels.rb', line 17

def parse(subject)
  words = subject.text.split(/\s+/).select{|str| str.match(NO_VOWELS_REGEX)}
  unless words.empty?
    subject.register_match!({:score => ((words.length ** 2).to_f / 100) , :filter => self})
  end
end