mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Tidy up a bit this code
This commit is contained in:
parent
1a0f72d0e3
commit
31ac1db596
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue