diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-10-18 09:49:04 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-10-18 09:49:04 -0200 |
commit | 31ac1db59600e00eeb098e29b43c073f239e2a1d (patch) | |
tree | 59df20674edef03e9f8488b8787cabf7b98b2076 /actionpack/lib/action_view | |
parent | 1a0f72d0e347b23f4f402f3c6d427eb73386b36d (diff) | |
download | rails-31ac1db59600e00eeb098e29b43c073f239e2a1d.tar.gz rails-31ac1db59600e00eeb098e29b43c073f239e2a1d.tar.bz2 rails-31ac1db59600e00eeb098e29b43c073f239e2a1d.zip |
Tidy up a bit this code
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/number_helper.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 0bb1cdea51..b2842f5f8c 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -63,14 +63,16 @@ module ActionView extension = options[:extension] country_code = options[:country_code] - str = "" - str << "+#{country_code}#{delimiter}" unless country_code.blank? - str << if area_code + if area_code number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4}$)/,"(\\1) \\2#{delimiter}\\3") else number.gsub!(/([0-9]{0,3})([0-9]{3})([0-9]{4})$/,"\\1#{delimiter}\\2#{delimiter}\\3") - number.starts_with?('-') ? number.slice!(1..-1) : number + number.slice!(0, 1) if number.starts_with?('-') end + + str = "" + str << "+#{country_code}#{delimiter}" unless country_code.blank? + str << number str << " x #{extension}" unless extension.blank? html_escape(str) end |