class Topical::TopicTree def find_most_specific(path, alternatives) # Assume the path with least '*' is the most fitting one... alternatives.find_all { |(topic, view)| path =~ self.class.path2regexp(topic, false) }.min { |a, b| a.count('*') <=> b.count('*') } end end