Class: SpamHam
- Inherits:
-
Object
- Object
- SpamHam
- Defined in:
- lib/spamham.rb,
lib/spamham/link.rb,
lib/spamham/scan.rb,
lib/spamham/version.rb,
lib/spamham/wordlist.rb,
lib/spamham/configure.rb
Defined Under Namespace
Classes: Link
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #conf(config = nil) ⇒ Object
-
#initialize ⇒ SpamHam
constructor
A new instance of SpamHam.
- #scan ⇒ Object
- #spam?(string) ⇒ Boolean
- #weight ⇒ Object
- #wordlist ⇒ Object
Constructor Details
#initialize ⇒ SpamHam
Returns a new instance of SpamHam.
7 8 9 |
# File 'lib/spamham.rb', line 7 def initialize self.conf end |
Instance Method Details
#conf(config = nil) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/spamham/configure.rb', line 2 def conf(config = nil) @config = config || {} load_config_from_defaults if File.exist?("config/spamham.rb") load_config_from_file end end |
#scan ⇒ Object
2 3 4 5 6 |
# File 'lib/spamham/scan.rb', line 2 def scan @string_weight = 0 build_link_weights build_word_list_weights end |
#spam?(string) ⇒ Boolean
11 12 13 14 15 16 |
# File 'lib/spamham.rb', line 11 def spam?(string) @string=string self.scan @string=nil @string_weight >= @config[:trigger_weight] end |
#weight ⇒ Object
18 19 20 |
# File 'lib/spamham.rb', line 18 def weight @string_weight end |
#wordlist ⇒ Object
2 3 4 |
# File 'lib/spamham/wordlist.rb', line 2 def wordlist YAML.load_file(File.dirname(__FILE__) + "/wordlist.yml")["words"] + (@config[:additional_words] || []) end |