Place the ricotta in the centre of a piece of muslin and bring up the edges to form a bag. Twist hard to extract as much of the moisture as possible. Place in a bowl with the parmesan, egg yolks, basil, nutmeg and flour. Season with black pepper and mix until well combined.
Cover a baking tray with a good layer of semolina. Take a spoonful of the ricotta mixture in your hands, shape it into a ball and roll it in the semolina until it’s well coated. Repeat until you have finished the mixture, and have around 20 balls. Chill for 1 hour in the fridge.
Meanwhile, heat the olive oil in a large pan and fry the onion over a gentle heat for 8-10 minutes until soft, but not coloured, adding the garlic for the last 2 minutes. Add the tomatoes and sugar and simmer gently for another 15 minutes until the tomatoes have reduced. Season and keep warm.
Bring a large pan of salted water to the boil and poach the gnudi for 5 minutes, or until they rise to the top of the surface. You may have to do this in batches, depending on the size of the pan. Remove with a slotted spoon. Serve with the tomato sauce spooned over and a few shavings of parmesan sprinkled on top.