aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremaxi <emaxi.gonzalez@gmail.com>2017-11-11 22:47:34 -0300
committeremaxi <emaxi.gonzalez@gmail.com>2018-07-11 20:59:51 -0300
commit6e1a536ad46fcd26f90ce2c0c47c66df45e67012 (patch)
tree77b241a7581d92e314b53978a1fe68ffd333470c
parent4a65dfcb9adae8fb12a86521c1a34b392e6084c2 (diff)
downloadrails-6e1a536ad46fcd26f90ce2c0c47c66df45e67012.tar.gz
rails-6e1a536ad46fcd26f90ce2c0c47c66df45e67012.tar.bz2
rails-6e1a536ad46fcd26f90ce2c0c47c66df45e67012.zip
Add missing documentation options to number_to_currency [ci skip]
-rw-r--r--actionview/lib/action_view/helpers/number_helper.rb5
-rw-r--r--activesupport/lib/active_support/number_helper.rb5
2 files changed, 10 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb
index 4b53b8fe6e..35206b7e48 100644
--- a/actionview/lib/action_view/helpers/number_helper.rb
+++ b/actionview/lib/action_view/helpers/number_helper.rb
@@ -100,6 +100,9 @@ module ActionView
# absolute value of the number.
# * <tt>:raise</tt> - If true, raises +InvalidNumberError+ when
# the argument is invalid.
+ # * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
+ # insignificant zeros after the decimal separator (defaults to
+ # +false+).
#
# ==== Examples
#
@@ -117,6 +120,8 @@ module ActionView
# # => R$1234567890,50
# number_to_currency(1234567890.50, unit: "R$", separator: ",", delimiter: "", format: "%n %u")
# # => 1234567890,50 R$
+ # number_to_currency(1234567890.50, strip_insignificant_zeros: true)
+ # # => "$1,234,567,890.5"
def number_to_currency(number, options = {})
delegate_number_helper_method(:number_to_currency, number, options)
end
diff --git a/activesupport/lib/active_support/number_helper.rb b/activesupport/lib/active_support/number_helper.rb
index 8fd6e932f1..c75ad52b0c 100644
--- a/activesupport/lib/active_support/number_helper.rb
+++ b/activesupport/lib/active_support/number_helper.rb
@@ -85,6 +85,9 @@ module ActiveSupport
# number given by <tt>:format</tt>). Accepts the same fields
# than <tt>:format</tt>, except <tt>%n</tt> is here the
# absolute value of the number.
+ # * <tt>:strip_insignificant_zeros</tt> - If +true+ removes
+ # insignificant zeros after the decimal separator (defaults to
+ # +false+).
#
# ==== Examples
#
@@ -100,6 +103,8 @@ module ActiveSupport
# # => "&pound;1234567890,50"
# number_to_currency(1234567890.50, unit: '&pound;', separator: ',', delimiter: '', format: '%n %u')
# # => "1234567890,50 &pound;"
+ # number_to_currency(1234567890.50, strip_insignificant_zeros: true)
+ # # => "$1,234,567,890.5"
def number_to_currency(number, options = {})
NumberToCurrencyConverter.convert(number, options)
end