Critical Path Method implementation in Ruby