Class: Splam::Rules::Chinese
- Inherits:
-
Splam::Rule
- Object
- Splam::Rule
- Splam::Rules::Chinese
- Defined in:
- lib/splam/rules/chinese.rb
Class Attribute Summary collapse
-
.base_score ⇒ Object
Returns the value of attribute base_score.
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
Class Attribute Details
.base_score ⇒ Object
Returns the value of attribute base_score.
4 5 6 |
# File 'lib/splam/rules/chinese.rb', line 4 def base_score @base_score end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/splam/rules/chinese.rb', line 8 def run banned_words =[ # various chinese characters "\350\263\207", "\351\207\221", "\357\274\222", # number 2 in weird unicode "\357\274\224", # number 4 "\357\274\225", # number 5 "\357\274\231", # number 9 "\345\260\232", "\345\256\266", "\345\274\267", "\345\240\261", "\345\260\216", "\345\217\260", "\345\215\227", "\346\235\261", "\345\270\202", "\345\240\264", "\345\202\263", "\346\216\250", "\346\231\202", "\347\203\210", "\347\216\251", "\350\226\246", "\350\217\234", "\350\216\216", "\357\274\215", # hyphen # /\\357\2\d\d\\\d{3}/, # TODO SyntaxError on 1.9 # "\357", # ugh, these don't work .. because they're only part of a character. # "\351", "\35" ].compact banned_words.each do |word| hits = (self.class.base_score * @body.scan(word).size) # 1 point for every banned word add_score hits, "Banned character: #{word}" end end |