module Dossier::Formatter

Public Instance Methods

commafy_number(value, precision = nil) click to toggle source
# File lib/dossier/formatter.rb, line 15
def commafy_number(value, precision = nil)
  whole, fraction = value.to_s.split('.')
  fraction = "%.#{precision}d" % (BigDecimal.new("0.#{fraction}").round(precision) * 10**precision).to_i if precision
  [whole.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,"), fraction].compact.join('.')
end
number_to_currency_from_cents(value) click to toggle source
# File lib/dossier/formatter.rb, line 7
def number_to_currency_from_cents(value)
  number_to_currency(value /= 100.0)
end
number_to_dollars(value) click to toggle source
# File lib/dossier/formatter.rb, line 11
def number_to_dollars(value)
  commafy_number(value, 2).sub(/(\d)/, '$\1')
end
report_name(report) click to toggle source
# File lib/dossier/formatter.rb, line 25
def report_name(report)
  titleize("#{report.report_name.split('/').last} Report")
end
url_formatter() click to toggle source
# File lib/dossier/formatter.rb, line 21
def url_formatter
  @url_formatter ||= UrlFormatter.new
end