Replace string evaluation with regular Ruby code

Strings of code with *eval() are generally error-prone and hard to read. In this case, regular Ruby code is safer (and even a bit shorter).