Ruby FuzzyHash

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'
Get a FREE sample chapter

Get a sample chapter of Clean Ruby and you'll be added to my periodic newsletter of helpful Ruby tips.