class FoodCritic::Linter
def matches(match_method, *params)
def matches(match_method, *params) return [] unless match_method.respond_to?(:yield) matches = match_method.yield(*params) return [] unless matches.respond_to?(:each) # We convert Nokogiri nodes to matches transparently matches.map do |m| if m.respond_to?(:node_name) match(m) elsif m.respond_to?(:xpath) m.to_a.map { |n| match(n) } else m end end.flatten end