Rubyficate some Pythonic if statement