code from my Rally reporting (ruby)