A man was left with a broken ankle following an assault on board a train travelling between Glasgow and Ayrshire.