Class: Gluttonberg::Content::Despamilator::Filter
- Inherits:
-
Object
- Object
- Gluttonberg::Content::Despamilator::Filter
- Defined in:
- lib/gluttonberg/content/despamilator/filter.rb
Overview
This class is the base class of all the despamilator filters.
EXAMPLE:
This example is to detect the letter “a”. Put the code in lib/despamilator/filter/detect_letter_a.rb:
require 'despamilator/filter_base'
module DespamilatorFilter
class DetectLetterA < Despamilator::FilterBase
def name
'Detecting the letter A'
end
def description
'Detects the letter "a" in a string for no reason other than a demo'
end
def parse text
if text.downcase.scan(/a/)
# add 0.1 to the score of the text
self.append_score = 0.1
end
end
end
Direct Known Subclasses
Gluttonberg::Content::DespamilatorFilter::Emails, Gluttonberg::Content::DespamilatorFilter::GtubsTestFilter, Gluttonberg::Content::DespamilatorFilter::HtmlTags, Gluttonberg::Content::DespamilatorFilter::IPAddressURL, Gluttonberg::Content::DespamilatorFilter::LongWords, Gluttonberg::Content::DespamilatorFilter::MixedCase, Gluttonberg::Content::DespamilatorFilter::NaughtyWords, Gluttonberg::Content::DespamilatorFilter::NoVowels, Gluttonberg::Content::DespamilatorFilter::NumbersAndWords, Gluttonberg::Content::DespamilatorFilter::ObfuscatedURLs, Gluttonberg::Content::DespamilatorFilter::Prices, Gluttonberg::Content::DespamilatorFilter::ScriptTag, Gluttonberg::Content::DespamilatorFilter::Shouting, Gluttonberg::Content::DespamilatorFilter::SpammyTLDs, Gluttonberg::Content::DespamilatorFilter::SquareBrackets, Gluttonberg::Content::DespamilatorFilter::TrailingNumber, Gluttonberg::Content::DespamilatorFilter::URLs, Gluttonberg::Content::DespamilatorFilter::UnusualCharacters, Gluttonberg::Content::DespamilatorFilter::VeryLongDomainName, Gluttonberg::Content::DespamilatorFilter::WeirdPunctuation
Instance Method Summary collapse
-
#description ⇒ Object
The nice description of the filter.
-
#name ⇒ Object
The one or two word name for the filter.
-
#parse(text) ⇒ Object
This method parses some text.
Instance Method Details
#description ⇒ Object
The nice description of the filter. Usually no more than a sentence.
38 39 40 |
# File 'lib/gluttonberg/content/despamilator/filter.rb', line 38 def description raise "No description defined for #{self.class}" end |
#name ⇒ Object
The one or two word name for the filter.
50 51 52 |
# File 'lib/gluttonberg/content/despamilator/filter.rb', line 50 def name raise "No name defined for #{self.class}" end |
#parse(text) ⇒ Object
This method parses some text. The score is assigned to the same instance.
44 45 46 |
# File 'lib/gluttonberg/content/despamilator/filter.rb', line 44 def parse text raise "No parser defined for #{self.class}" end |