class PDD::Rule::Roles::Available
Rule
for available roles checking.
Public Class Methods
new(xml, roles)
click to toggle source
Ctor.
xml
-
XML with puzzles
# File lib/pdd/rule/roles.rb, line 28 def initialize(xml, roles) @xml = xml @roles = roles.split(',') end
Public Instance Methods
errors()
click to toggle source
# File lib/pdd/rule/roles.rb, line 33 def errors @xml.xpath('//puzzle').map do |p| role = p.xpath('role/text()').to_s next nil if @roles.include?(role) "puzzle #{p.xpath('file/text()')}:#{p.xpath('lines/text()')}" + if role.empty? " doesn't define any role"\ ", while one of these roles is required: #{@roles}" else " defines role #{role}"\ ", while only these roles are allowed: #{@roles}" end end.compact end