Rotary Encoder Help

Hi folks - can anyone advise on the best approach (code would be great) to measuring the speed or distance a rotary encoder has been rotated (mean change) from when it is started turning to when it is no longer turning anymore. Much appreciated! Im using the 1024 from Sparkfun Rotary Encoder - 1024 P/R (Quadrature) - COM-11102 - SparkFun Electronics?