Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size.
| Public Methods | |
|---|---|
| number_ |
Formats a number into a currency string (e.g., $13.65). You can customize the format in the options hash. |
| number_ |
Formats the bytes in size into a more understandable representation (e.g., giving it 1500 yields 1.5 KB). This method is useful for reporting file sizes to users. This method returns nil if size cannot be converted into a number. You can change the default precision of 1 using the precision parameter precision. |
| number_ |
Formats a number as a percentage string (e.g., 65%). You can customize the format in the options hash. |
| number_ |
Formats a number into a US phone number (e.g., (555) 123-9876). You can customize the format in the options hash. |
| number_ |
Formats a number with grouped thousands using delimiter (e.g., 12,324). You can customize the format using optional delimiter and separator parameters. |
| number_ |
Formats a number with the specified level of precision (e.g., 112.32 has a precision of 2). The default level of precision is 3. |
<code/>and<pre/>for code samples.