Math.atan2(y,x) is the function that you are looking for.
to get an angle from the ramp effect's start and end points, try this: L = thisComp.layer("Layer with Ramp Effect");
p1 = L.effect("Gradient Ramp")("Start of Ramp");
p2 = L.effect("Gradient Ramp")("End of Ramp");
p = p2 - p1;
radiansToDegrees( Math.atan2( p, p ) );
depending on where you want zero degrees to start, you may need to add or subtract 90 degrees (currently zero is pointing right)