convert BAC calc to ruby