ruby inject rewrite