Module: Hanami::Helpers::NumberFormattingHelper
- Defined in:
- gems/gems/hanami-helpers-1.3.1/lib/hanami/helpers/number_formatting_helper.rb,
gems/gems/hanami-helpers-1.3.3/lib/hanami/helpers/number_formatting_helper.rb
Overview
Number formatter
You can include this module inside your view and the view will have access all methods.
By including Hanami::Helpers::NumberFormattingHelper
it will inject private method: format_number
.
Instance Method Summary collapse
-
#format_number(number, options = {}) ⇒ String
private
Format the given number, according to the options.
Instance Method Details
#format_number(number, options = {}) ⇒ String (private)
Format the given number, according to the options
It accepts a number (Numeric
) or a string representation.
If an integer is given, no precision is applied. For the rest of the numbers, it will format as a float representation. This is the case of: Float
, BigDecimal
, Complex
, Rational
.
If the argument cannot be coerced into a number, it will raise a TypeError
.
Source: | on GitHub
def format_number(number, = {}) Formatter.new(number, ).format end |