change `inject` to `each_with_object` because this isn't a reduction

Each iteration doesn't depend on the result of the previous (this isn't a reduction), so we can use `each_with_object` and avoid passing each return value to the next iteration.