Mario isn't the best at Ledge-trapping. Mario usually needs to choose one option, and go for a hard read, especially against Ridley. Standing in-between the area for a roll getup and neutral getup and holding shield is usually the way to go if your trying to read a neutral getup or getup attack, Ridley could drop from ledge and nair, swating you away, to make an option in peace. This is a good option for Ridley, because of his multi-jumps. It's really hard to ledge-trap as Mario period, so just choose and option and go for a hard read, or don't ledge-trap at all.
Mario