use alternative syntax to avoid errors with Ruby 2.2

Ruby 2.2 seems to have a problem with blocks and the ternary operator.

This ~~stupid~~simple trick should be sufficient.

See https://www.ruby-forum.com/topic/6664839