This paper provides a mathematical analysis to calculate the number of longitudinal modes and their relative strength in a dye Q-switched ruby laser. The calculations were based on formulae developed to accurately predict the number of loop transmits that occur while the laser pulse builds up from noise levels. An experiment was carried out using a ruby laser set-up to confirm our theoretical predictions. The number of longitudinal modes present in the laser output was evaluated by recording holograms of a two meter long graduated panel using the same laser source. The end results closely matched our theoretical predictions. This proven mathematical analysis was then applied to our laser design to optimize the longitudinal mode selection property of the dye Q-switch in the laser. As a result, the developed ruby laser produced single longitudinal mode pulses at a probability of 98%.