On second thought, no need to reinvent the wheel here. A gem should work just fine.