提交 31ac1db5 编写于 作者: S Santiago Pastorino

Tidy up a bit this code

上级 1a0f72d0
......@@ -63,14 +63,16 @@ def number_to_phone(number, options = {})
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册