Class: Gluttonberg::Content::DespamilatorFilter::NoVowels

Inherits:
Gluttonberg::Content::Despamilator::Filter show all
Defined in:
lib/gluttonberg/content/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



15
16
17
# File 'lib/gluttonberg/content/despamilator/filter/no_vowels.rb', line 15

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

#nameObject



11
12
13
# File 'lib/gluttonberg/content/despamilator/filter/no_vowels.rb', line 11

def name
  'No Vowels'
end

#parse(subject) ⇒ Object



19
20
21
22
23
24
# File 'lib/gluttonberg/content/despamilator/filter/no_vowels.rb', line 19

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