diff code writing by ruby