On any gear, the ratio is determined by the distances from the center of the gear to the point of contact. For instance, in a device with two gears, if one gear is twice the diameter of the other, the ratio would be 2:1.
One of the most primitive types of gears we could look at would be a wheel with wooden pegs sticking out of it.
The problem with this type of gear is that the distance from the center of each gear to the point of contact changes as the gears rotate. This means that the gear ratio changes as the gear turns, meaning that the output speed also changes. If you used a gear like this in your car, it would be impossible to maintain a constant speed -- you would be accelerating and decelerating constantly.
Many modern gears use a special tooth profile called an involute. This profile has the very important property of maintaining a constant speed ratio between the two gears. Like the peg wheel above, the contact point moves; but the shape of the involute gear tooth compensates for this movement. See this section for details.
Now let's take a look at some of the different types of gears.