Constants instead of string allocations for Ruby < 2.1

It costs a bit of code readability but avoids allocating
new string objects repeatedly.