Ruby port of John Gruber's Title Case algorithm