Class: Splam::Rules::Punctuation
- Inherits:
-
Splam::Rule
- Object
- Splam::Rule
- Splam::Rules::Punctuation
- Defined in:
- lib/splam/rules/punctuation.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
#run ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/splam/rules/punctuation.rb', line 2 def run punctuation = @body.scan(/[.,] /) add_score 10, "Text has no punctuation" if punctuation.size == 0 @body.split(/[.,]/).each do |sentence| words = sentence.split(" ") # long sentence, add a point. unless line_safe?(sentence) add_score 1, "Sentence has more than 10 words" if words.size > 10 add_score 10, "Sentence has more than 30 words" if words.size > 30 end end end |