aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/number_helper.rb
diff options
context:
space:
mode:
authorAkshay Vishnoi <akshay.vishnoi@vinsol.com>2014-06-10 23:07:49 +0530
committerAkshay Vishnoi <akshay.vishnoi@vinsol.com>2014-06-10 23:07:49 +0530
commit294ddff512eeacbebca4a679cd0f85614ea15576 (patch)
treed5423f719fea79fe92cb9dad10127765f0dc5ce0 /activesupport/lib/active_support/number_helper.rb
parent3681e1ac2c5448b9826f2e3c9b6508c50d2b4f17 (diff)
downloadrails-294ddff512eeacbebca4a679cd0f85614ea15576.tar.gz
rails-294ddff512eeacbebca4a679cd0f85614ea15576.tar.bz2
rails-294ddff512eeacbebca4a679cd0f85614ea15576.zip
[ci skip] Add Docs for strip_insignificant_zeros option in number helpers
Diffstat (limited to 'activesupport/lib/active_support/number_helper.rb')
-rw-r--r--activesupport/lib/active_support/number_helper.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/number_helper.rb b/activesupport/lib/active_support/number_helper.rb
index 7ddc7e505a..5ecda9593a 100644
--- a/activesupport/lib/active_support/number_helper.rb
+++ b/activesupport/lib/active_support/number_helper.rb
@@ -232,12 +232,8 @@ module ActiveSupport
# number_to_human_size(1234567, precision: 2) # => 1.2 MB
# number_to_human_size(483989, precision: 2) # => 470 KB
# number_to_human_size(1234567, precision: 2, separator: ',') # => 1,2 MB
- #
- # Non-significant zeros after the fractional separator are stripped out by
- # default (set <tt>:strip_insignificant_zeros</tt> to +false+ to change that):
- #
- # number_to_human_size(1234567890123, precision: 5) # => "1.1228 TB"
- # number_to_human_size(524288000, precision: 5) # => "500 MB"
+ # number_to_human_size(1234567890123, precision: 5) # => "1.1228 TB"
+ # number_to_human_size(524288000, precision: 5) # => "500 MB"
def number_to_human_size(number, options = {})
NumberToHumanSizeConverter.convert(number, options)
end
@@ -305,12 +301,15 @@ module ActiveSupport
# separator: ',',
# significant: false) # => "1,2 Million"
#
+ # number_to_human(500000000, precision: 5) # => "500 Million"
+ # number_to_human(12345012345, significant: false) # => "12.345 Billion"
+ #
# Non-significant zeros after the decimal separator are stripped
# out by default (set <tt>:strip_insignificant_zeros</tt> to
# +false+ to change that):
#
- # number_to_human(12345012345, significant: false) # => "12.345 Billion"
- # number_to_human(500000000, precision: 5) # => "500 Million"
+ # number_to_human(12.00001) # => "12"
+ # number_to_human(12.00001, strip_insignificant_zeros: false) # => "12.0"
#
# ==== Custom Unit Quantifiers
#