aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-12-03 19:57:44 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-12-03 20:26:57 -0200
commit59ba94e8a2e6e88cdf4e13d34e18fc7c53265407 (patch)
tree77b9065eef520641535e9deb15fa530dd1cd6483 /activesupport
parenta63d8cd9e165cecb3f083eb80fd0ac048464d312 (diff)
downloadrails-59ba94e8a2e6e88cdf4e13d34e18fc7c53265407.tar.gz
rails-59ba94e8a2e6e88cdf4e13d34e18fc7c53265407.tar.bz2
rails-59ba94e8a2e6e88cdf4e13d34e18fc7c53265407.zip
Change delimiter check order: first check if it is present
This reads a lot better, and we won't need to try start_with? for blank delimiters. Also rename method name to read better.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_phone_converter.rb6
1 files changed, 3 insertions, 3 deletions
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 045f86c10f..4c33c30772 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
@@ -24,12 +24,12 @@ module ActiveSupport
def convert_without_area_code(number)
number.gsub!(/(\d{0,3})(\d{3})(\d{4})$/,"\\1#{delimiter}\\2#{delimiter}\\3")
- number.slice!(0, 1) if begins_with_delimiter?(number)
+ number.slice!(0, 1) if start_with_delimiter?(number)
number
end
- def begins_with_delimiter?(number)
- number.start_with?(delimiter) && !delimiter.blank?
+ def start_with_delimiter?(number)
+ delimiter.present? && number.start_with?(delimiter)
end
def delimiter