How do you learn the Spanish/Ruy Lopez?

Honestly, here the main plans: The main idea is to play d4 by playing c3 first, so a pawn stays in the center after exd4. Bb5 also undermines Black's control of d4 (that's why you play Bb5 in the first place). After you get d4, try to play Nd2 Nf1 Ng3 Nf5 to attack on the kingside. White generally attacks on the kingside in the Ruy Lopez. You can also try to play for f4 sometimes. Your light-squared bishop should attack f7 once you are attacking to create a pin. That's roughly it.
Look at games and familiarize yourself with the most common lines. Here a bit of help: