Kiss A simpler, smarter web application framework for Ruby

BigDecimal Subclass of Object

Public Instance Methods

format_currency() source

Formats number to two decimal places.

    # File lib/kiss/model.rb, line 192
  def format_currency
    format_thousands(sprintf("%0.2f",to_f))
  end
    
format_thousands(value = to_f.to_s) source

Formats number with comma-separated thousands.

    # File lib/kiss/model.rb, line 186
  def format_thousands(value = to_f.to_s)
    integer, decimal = value.split(/\./,2)
    integer.reverse.gsub(/(\d{3})/,'\1,').sub(/\,(-?)$/,'\1').reverse + '.' + decimal
  end
    

Disabled; run with $DEBUG to generate this.