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’

Post a comment


(required, but not displayed)

(optional)



(required)

1999 - 2010 © Saturn Flyer LLC 1901 N. Moore St. Suite 206 Arlington, VA 22209

Call Jim Gay at 571 403 0338