5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/rubyfocus/includes/parser.rb', line 5
def self.parse(document, node)
matching_classes = @subclasses.select{ |klass| klass.matches_node?(node) }
if matching_classes.size > 1
classes_with_subclasses = matching_classes.select{ |c| matching_classes.any?{ |sc| sc < c } }
matching_classes = matching_classes - classes_with_subclasses
end
case matching_classes.size
when 0
nil
when 1
return matching_classes.first.new(document, node)
else
raise RuntimeError, "Node #{node.inspect} matches more than one Rubyfocus::Item subclass."
end
end
|