aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-12-03 19:49:19 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-12-03 20:26:56 -0200
commite56a553c9536225296a98f82d4625ee2b94a2b2f (patch)
tree6532e476691627276685fd47c0c32834ca2f3932 /activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
parent4e19ef9b25e7461be654c6e5bc085addbefc459e (diff)
downloadrails-e56a553c9536225296a98f82d4625ee2b94a2b2f.tar.gz
rails-e56a553c9536225296a98f82d4625ee2b94a2b2f.tar.bz2
rails-e56a553c9536225296a98f82d4625ee2b94a2b2f.zip
Stop using local variables everywhere, make use of the reader
Diffstat (limited to 'activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb')
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb b/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
index 37590c27ef..d1335f6910 100644
--- a/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
@@ -7,7 +7,7 @@ module ActiveSupport
self.validate_float = true
def convert
- @number = Float(@number)
+ @number = Float(number)
# for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
unless options.key?(:strip_insignificant_zeros)
@@ -15,9 +15,9 @@ module ActiveSupport
end
if smaller_than_base?
- number_to_format = @number.to_i.to_s
+ number_to_format = number.to_i.to_s
else
- human_size = @number / (base ** exponent)
+ human_size = number / (base ** exponent)
number_to_format = NumberToRoundedConverter.convert(human_size, options)
end
conversion_format.gsub(/%n/, number_to_format).gsub(/%u/, unit)
@@ -30,7 +30,7 @@ module ActiveSupport
end
def unit
- translate_number_value_with_default(storage_unit_key, :locale => options[:locale], :count => @number.to_i, :raise => true)
+ translate_number_value_with_default(storage_unit_key, :locale => options[:locale], :count => number.to_i, :raise => true)
end
def storage_unit_key
@@ -40,13 +40,13 @@ module ActiveSupport
def exponent
max = STORAGE_UNITS.size - 1
- exp = (Math.log(@number) / Math.log(base)).to_i
+ exp = (Math.log(number) / Math.log(base)).to_i
exp = max if exp > max # avoid overflow for the highest unit
exp
end
def smaller_than_base?
- @number.to_i < base
+ number.to_i < base
end
def base