 # Author:
 #   jhubert
 
-Number.prototype.toDollars = (currency_symbol = (process.env.HUBOT_CASH_CURRENCY_SYMBOL or '$'), thousands_separator = (process.env.HUBOT_CASH_THOUSANDS_SEPARATOR or ',')) ->
-    n = this
+class OutputFormatter
+  months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
+
+  constructor: ->
+    return
+
+  toDollars: (number, currency_symbol = (process.env.HUBOT_CASH_CURRENCY_SYMBOL or '$'), thousands_separator = (process.env.HUBOT_CASH_THOUSANDS_SEPARATOR or ',')) ->
+    n = parseInt(number, 10)
     sign = if n < 0 then "-" else ""
     i = parseInt(n = Math.abs(n).toFixed(0)) + ''
     j = if (j = i.length) > 3 then j % 3 else 0

    y = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_separator)
    sign + currency_symbol + x + y

Date.months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
Date::getNiceDate = ->
  Date.months[@getMonth()] + ' ' + @getDate() + ', ' + @getFullYear()

Date::getMonthName = ->
  Date.months[@getMonth()]

class Cash
  constructor: (@robot) ->

        else
          diff_type = 'less'

        output += ", which is #{optf.toDollars(Math.abs(diff))} #{diff_type} than on #{optf.toNiceDate(last_cash.date)}. "
      else
        output += "."

      output += "\nAt our current burn rate (#{optf.toDollars(current_burn.rate)} / month), we have #{months} months left. That gets us to #{optf.getMonthName(end_date)} #{end_date.getFullYear()}."

      msg.send output
    else
