2006-06-02
[Bilbo]spamフィルター実装案
spam?メソッドを自分で書けるようにすればいいのだろうか。
def spam? entry return true if default_filter.spam?(entry) entry.body =~ /href/i end if __FILE__ == $0 require 'test/unit' class SpamFilterTest < Test::Unit::TestCase def test_spam? entry = Entry.new(:body => 'aaa') assert !spam?(entry) entry = Entry.new(:body => '<a href=...') assert spam?(entry) end end end