diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-06 16:22:00 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-06 16:22:05 -0200 |
commit | d7318599160dbc6d362793673e8c6db926eeb7b8 (patch) | |
tree | 9177820d0c8c93358ca39e3c5d3b0ca71ad1e7cf /activesupport/lib/active_support/number_helper.rb | |
parent | 01c86fbf84155095e258aa3ccfaad66374810ad1 (diff) | |
parent | 2d2bcde3cb80ee7d51dc3ad056dfe9d808a95389 (diff) | |
download | rails-d7318599160dbc6d362793673e8c6db926eeb7b8.tar.gz rails-d7318599160dbc6d362793673e8c6db926eeb7b8.tar.bz2 rails-d7318599160dbc6d362793673e8c6db926eeb7b8.zip |
Merge branch 'rm-ntp'
Merge #12067 rebasing and improving the code.
Diffstat (limited to 'activesupport/lib/active_support/number_helper.rb')
-rw-r--r-- | activesupport/lib/active_support/number_helper.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/number_helper.rb b/activesupport/lib/active_support/number_helper.rb index 34439ee8be..cfca42bc69 100644 --- a/activesupport/lib/active_support/number_helper.rb +++ b/activesupport/lib/active_support/number_helper.rb @@ -94,7 +94,7 @@ module ActiveSupport # * <tt>:locale</tt> - Sets the locale to be used for formatting # (defaults to current locale). # * <tt>:precision</tt> - Sets the precision of the number - # (defaults to 3). + # (defaults to 3). Keeps the number's precision if nil. # * <tt>:significant</tt> - If +true+, precision will be the # # of significant_digits. If +false+, the # of fractional # digits (defaults to +false+). @@ -116,6 +116,7 @@ module ActiveSupport # number_to_percentage(1000, delimiter: '.', separator: ',') # => 1.000,000% # number_to_percentage(302.24398923423, precision: 5) # => 302.24399% # number_to_percentage(1000, locale: :fr) # => 1 000,000% + # number_to_percentage:(1000, precision: nil) # => 1000% # number_to_percentage('98a') # => 98a% # number_to_percentage(100, format: '%n %') # => 100 % def number_to_percentage(number, options = {}) @@ -161,7 +162,7 @@ module ActiveSupport # * <tt>:locale</tt> - Sets the locale to be used for formatting # (defaults to current locale). # * <tt>:precision</tt> - Sets the precision of the number - # (defaults to 3). + # (defaults to 3). Keeps the number's precision if nil. # * <tt>:significant</tt> - If +true+, precision will be the # # of significant_digits. If +false+, the # of fractional # digits (defaults to +false+). @@ -182,6 +183,7 @@ module ActiveSupport # number_to_rounded(111.2345, significant: true) # => 111 # number_to_rounded(111.2345, precision: 1, significant: true) # => 100 # number_to_rounded(13, precision: 5, significant: true) # => 13.000 + # number_to_rounded(13, precision: nil) # => 13 # number_to_rounded(111.234, locale: :fr) # => 111,234 # # number_to_rounded(13, precision: 5, significant: true, strip_insignificant_zeros: true) |