Ruby code to solve the task of dependent jobs scheduling