Transformed bash into ruby script