Class: Splam::Rules::Russian

Inherits:
Splam::Rule show all
Defined in:
lib/splam/rules/russian.rb

Instance Attribute Summary

Attributes inherited from Splam::Rule

#body, #reasons, #score, #suite, #weight

Instance Method Summary collapse

Methods inherited from Splam::Rule

#add_score, inherited, #initialize, #line_safe?, #name, run

Constructor Details

This class inherits a constructor from Splam::Rule

Instance Method Details

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/splam/rules/russian.rb', line 4

def run
  banned_words =[ # various russian characters
    "\320\241", "\320\220", "\320\234", "\320\257", "\320\233", "\320\243", 
    "с", "м", "о", "т", "р", "е", "т", "ь", "п", "о", "р", "н", "о", "р", "л", "и", "к"
    # unicode char
#      "\320"
  ]
  banned_words.each do |word|
    hits = (3 * @body.scan("#{word}").size) # 1 point for every banned word
    add_score hits, "Suspicious character '#{word}'"
  end
end