Use delete instead of gsub
Break-down trinary conditional operator
Use chomp instead of cryptic String#[]