aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-12-02 22:31:05 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-12-02 22:32:22 -0200
commitd7d11f0dab7f2875d04c17921e12fe62ac6e9566 (patch)
tree7f30fed78a0854fc031aed15db5ad4d5c261cea4 /activesupport
parentd752ae16abd5f1e48983fc12e18f50cba1896131 (diff)
downloadrails-d7d11f0dab7f2875d04c17921e12fe62ac6e9566.tar.gz
rails-d7d11f0dab7f2875d04c17921e12fe62ac6e9566.tar.bz2
rails-d7d11f0dab7f2875d04c17921e12fe62ac6e9566.zip
:sicssors:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/number_helper/number_converter.rb4
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_currency_converter.rb2
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb2
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_human_converter.rb2
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb2
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb2
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_phone_converter.rb1
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb2
8 files changed, 2 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_converter.rb b/activesupport/lib/active_support/number_helper/number_converter.rb
index 157d7820c3..4bc8b4a8e7 100644
--- a/activesupport/lib/active_support/number_helper/number_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_converter.rb
@@ -7,7 +7,6 @@ require 'active_support/core_ext/class/attribute'
module ActiveSupport
module NumberHelper
class NumberConverter # :nodoc:
-
# Default and i18n option namespace per class
class_attribute :namespace
@@ -149,9 +148,11 @@ module ActiveSupport
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 @@ module ActiveSupport
rescue ArgumentError, TypeError
false
end
-
end
end
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb b/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb
index 90a3cede3a..28f33164a5 100644
--- a/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb
+++ b/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 @@ module ActiveSupport
i18n[:negative_format] ||= "-#{i18n[:format]}" if i18n[:format]
i18n
end
-
end
end
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb
index 6604b9cce4..2b5dbd1d5a 100644
--- a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb
+++ b/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 @@ module ActiveSupport
left.gsub!(DELIMITED_REGEX) { "#{$1}#{options[:delimiter]}" }
[left, right].compact
end
-
end
end
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_human_converter.rb b/activesupport/lib/active_support/number_helper/number_to_human_converter.rb
index 0c1a7250e3..9cdc18c373 100644
--- a/activesupport/lib/active_support/number_helper/number_to_human_converter.rb
+++ b/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 @@ module ActiveSupport
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
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 467ad030b5..33fc6e3553 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
@@ -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 @@ module ActiveSupport
def base
opts[:prefix] == :si ? 1000 : 1024
end
-
end
end
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb b/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb
index c654bfaa3a..eafe2844f7 100644
--- a/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb
+++ b/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
diff --git a/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb b/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb
index c4aa5c311a..9828bec053 100644
--- a/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb
@@ -44,7 +44,6 @@ module ActiveSupport
def phone_ext(ext)
ext.blank? ? "" : " x #{ext}"
end
-
end
end
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
index 820e1534e2..ab430bbc7a 100644
--- a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
+++ b/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 @@ module ActiveSupport
number
end
end
-
end
end
end