Ruby FuzzyHash
by Jim Gay
I came across an interesting way to use a Hash at http://github.com/joshbuddy/fuzzyhash/tree/master.
I may look into this further for Vapor since this is basically what that RadiantCMS extension needs to do.
I’ve altered the sample code but it does all the explaining:
hash = FuzzyHash.new
hash[/\d+$/] = ‘number'
hash[/.*/] = 'something'
hash['chunky’] = ‘bacon'
hash['foo’] = ‘vader’hash[‘foo’] #=> ‘vader'
hash['food’] #=> ‘something'
hash['123’] #=> ‘number’