Class: DespamilatorFilter::URLs

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

Instance Method Summary collapse

Instance Method Details

#descriptionObject



11
12
13
# File 'lib/despamilator/filter/urls.rb', line 11

def description
  'Detects each url in a string'
end

#nameObject



7
8
9
# File 'lib/despamilator/filter/urls.rb', line 7

def name
  'URLs'
end

#parse(subject) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/despamilator/filter/urls.rb', line 15

def parse subject
  text = subject.text.downcase.gsub(/http:\/\/\d+\.\d+\.\d+\.\d+/, '')
  matches = text.count(/https?:\/\//)
  1.upto(matches > 2 ? 2 : matches) do
    subject.register_match!({:score => 0.4, :filter => self})
  end
end