Class: PDD::Rule::Text::MinWords
- Inherits:
-
Object
- Object
- PDD::Rule::Text::MinWords
- Defined in:
- lib/pdd/rule/text.rb
Overview
Rule for minimum length of description.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(xml, min) ⇒ MinWords
constructor
Ctor.
Constructor Details
#initialize(xml, min) ⇒ MinWords
Ctor.
xml
-
XML with puzzles
28 29 30 31 |
# File 'lib/pdd/rule/text.rb', line 28 def initialize(xml, min) @xml = xml @min = min.to_i end |
Instance Method Details
#errors ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/pdd/rule/text.rb', line 33 def errors @xml.xpath('//puzzle').map do |p| words = p.xpath('body/text()').to_s.split.size next nil if words >= @min "Puzzle #{p.xpath('file/text()')}:#{p.xpath('lines/text()')}"\ " has a very short description of just #{words} words while"\ " a minimum of #{@min} is required" end.compact end |