Module

NumberHelper

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_to_currency Formats a number into a currency string (e.g., $13.65). You can customize the format in the options hash.
number_to_human_size 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_to_percentage Formats a number as a percentage string (e.g., 65%). You can customize the format in the options hash.
number_to_phone Formats a number into a US phone number (e.g., (555) 123-9876). You can customize the format in the options hash.
number_with_delimiter Formats a number with grouped thousands using delimiter (e.g., 12,324). You can customize the format using optional delimiter and separator parameters.
number_with_precision 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.
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.