The Spanish midfielder broke through after 57 minutes to get Gennaro Gattuso’s side back to winning ways after their 3-2 league defeat at home to lowly Lecce last weekend.
Ruiz picked up a Giovanni Di Lorenzo cross, beating three Inter defenders to curl in past a helpless Daniele Padelli.
Antonio Conte’s side looked sluggish days after their thrilling 4-2 derby win over AC Milan which put them top of the Serie A table.
Both sides had their chances in the first half with Lautaro Martínez nodding wide with Padelli denying Piotr Zielinski just before the break in front of a crowd of nearly 60,000 in northern Italy.
Conte sent on Cristian Eriksen after 65 minutes and the Dane threatened but David Ospina held firm in the Napoli goal.
Napoli, who last won the trophy in 2014, now take a slim advantage into the second leg at their Stadio San Paolo on March 5.
Record 18-time winners Juventus take on AC Milan in the other semi-final on Thursday, again in the San siro.
The match will be the first clash in Italy between Juventus star Cristiano Ronaldo and Sweden’s Zlatan Ibrahimovic.
The final will take place in the Stadio Olimpico in Rome on May 13.