Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.



			
class Array
  def extract_options!
    last.is_a?(::Hash) ? pop : {}
  end
end

class Hash
  def reverse_merge(other_hash)
    other_hash.merge(self)
  end

  def reverse_merge!(other_hash)
    replace(reverse_merge(other_hash))
  end
end

def number_with_delimiter(number, *args)
  # extract hash to support new API
  options = args.extract_options!
  # check array to support current API
  if args.size > 0
    options[:delimiter] = args[0] || ","
    options[:separator] = args[1] || "."
  end
  options.reverse_merge!(:delimiter => ",", :separator => ".")

  begin
    parts = number.to_s.split('.')
    parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
    parts.join options[:separator]
  rescue
    number
  end
end

puts number_with_delimiter(1999.99)
puts number_with_delimiter(1999.99, ".")
puts number_with_delimiter(1999.99, :separator => ",", :delimiter => ".")
puts number_with_delimiter(1999.99, :separator => ",")