Question

dookie's avatar

What's the equivalent to PHP's number_format method in Ruby?

Asked by dookie (46points) | asked June 19th, 2008 | 2 responses | “Great Question” (0points) | Flag as…

PHP’s number_format method converts 1234 to 1,234 (adding the comma). In Ruby, it would need to be a method on an Fixnum (or a Float) that would return a String.

Observing members: 0 Composing members: 0

Answers

sferik's avatar

In Rails, you can use the format method. For example:

>> 1234.format
=> "1,234"
sferik's avatar

The format method is deprecated in Rails 2.1.

It is replaced by the number_with_delimiter method.

Answer this question

Login

or

Join

to answer.
Your answer will be saved while you login or join.

Have a question about something? Ask Fluther!