Skip to content
Browse files

:sicssors:

  • Loading branch information...
1 parent d752ae1 commit d7d11f0dab7f2875d04c17921e12fe62ac6e9566 @rafaelfranca rafaelfranca committed Dec 2, 2013
View
4 activesupport/lib/active_support/number_helper/number_converter.rb
@@ -7,7 +7,6 @@
module ActiveSupport
module NumberHelper
class NumberConverter # :nodoc:
-
# Default and i18n option namespace per class
class_attribute :namespace
@@ -149,9 +148,11 @@ def default_format_options #:nodoc:
def i18n_format_options #:nodoc:
locale = opts[:locale]
options = I18n.translate(:'number.format', locale: locale, default: {}).dup
+
if namespace
options.merge!(I18n.translate(:"number.#{namespace}.format", locale: locale, default: {}))
end
+
options
end
@@ -172,7 +173,6 @@ def valid_float? #:nodoc:
rescue ArgumentError, TypeError
false
end
-
end
end
end
View
2 activesupport/lib/active_support/number_helper/number_to_currency_converter.rb
@@ -1,7 +1,6 @@
module ActiveSupport
module NumberHelper
class NumberToCurrencyConverter < NumberConverter # :nodoc:
-
self.namespace = :currency
def convert
@@ -42,7 +41,6 @@ def i18n_opts
i18n[:negative_format] ||= "-#{i18n[:format]}" if i18n[:format]
i18n
end
-
end
end
end
View
2 activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb
@@ -1,7 +1,6 @@
module ActiveSupport
module NumberHelper
class NumberToDelimitedConverter < NumberConverter #:nodoc:
-
self.need_valid_float = true
DELIMITED_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/
@@ -17,7 +16,6 @@ def parts
left.gsub!(DELIMITED_REGEX) { "#{$1}#{options[:delimiter]}" }
[left, right].compact
end
-
end
end
end
View
2 activesupport/lib/active_support/number_helper/number_to_human_converter.rb
@@ -1,7 +1,6 @@
module ActiveSupport
module NumberHelper
class NumberToHumanConverter < NumberConverter # :nodoc:
-
DECIMAL_UNITS = { 0 => :unit, 1 => :ten, 2 => :hundred, 3 => :thousand, 6 => :million, 9 => :billion, 12 => :trillion, 15 => :quadrillion,
-1 => :deci, -2 => :centi, -3 => :mili, -6 => :micro, -9 => :nano, -12 => :pico, -15 => :femto }
INVERTED_DECIMAL_UNITS = DECIMAL_UNITS.invert
@@ -62,7 +61,6 @@ def unit_exponents(units)
raise ArgumentError, ":units must be a Hash or String translation scope."
end.keys.map { |e_name| INVERTED_DECIMAL_UNITS[e_name] }.sort_by { |e| -e }
end
-
end
end
end
View
2 activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
@@ -1,7 +1,6 @@
module ActiveSupport
module NumberHelper
class NumberToHumanSizeConverter < NumberConverter
-
STORAGE_UNITS = [:byte, :kb, :mb, :gb, :tb]
self.namespace = :human
@@ -53,7 +52,6 @@ def smaller_than_base?
def base
opts[:prefix] == :si ? 1000 : 1024
end
-
end
end
end
View
2 activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb
@@ -1,14 +1,12 @@
module ActiveSupport
module NumberHelper
class NumberToPercentageConverter < NumberConverter # :nodoc:
-
self.namespace = :percentage
def convert
rounded_number = NumberToRoundedConverter.convert(number, options)
options[:format].gsub('%n', rounded_number)
end
-
end
end
end
View
1 activesupport/lib/active_support/number_helper/number_to_phone_converter.rb
@@ -44,7 +44,6 @@ def country_code(code)
def phone_ext(ext)
ext.blank? ? "" : " x #{ext}"
end
-
end
end
end
View
2 activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
@@ -1,7 +1,6 @@
module ActiveSupport
module NumberHelper
class NumberToRoundedConverter < NumberConverter # :nodoc:
-
self.namespace = :precision
self.need_valid_float = true
@@ -55,7 +54,6 @@ def format_number(number)
number
end
end
-
end
end
end

0 comments on commit d7d11f0

Please sign in to comment.
Something went wrong with that request. Please try again.