Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size.
Adapted from Rails Number Helpers.
The units available for storage formatting.
[:byte, :kb, :mb, :gb, :tb].freeze
#number_to_currency(number, options = {}) ⇒ String
Formats a number
into a currency string (e.g., $13.65). #number_to_human_size(number, options = {}) ⇒ String
Formats the bytes in size
into a more understandable representation (e.g., giving it 1500 yields 1.5 KB). #number_to_percentage(number, options = {}) ⇒ String
Formats a number
as a percentage string (e.g., 65%). #number_with_delimiter(number, options = {}) ⇒ String
Formats a number
with grouped thousands using delimiter
(e.g., 12,324). #number_with_precision(number, options = {}) ⇒ String
Formats a number
with the specified level of :precision
(e.g., 112.32 has a precision of 2). Formats a number
into a currency string (e.g., $13.65). You can customize the format in the options
hash.
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 customize the format in the options
hash.
Formats a number
as a percentage string (e.g., 65%). You can customize the format in the options
hash.
Formats a number
with grouped thousands using delimiter
(e.g., 12,324). You can customize the format in the options
hash.
Formats a number
with the specified level of :precision
(e.g., 112.32 has a precision of 2). You can customize the format in the options
hash.
© 2010–2019 Padrino
Licensed under the MIT License.
https://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Helpers/NumberHelpers