Module: HasPhone
- Extended by:
- ActiveSupport::Concern
- Included in:
- Contact
- Defined in:
- app/models/concerns/has_phone.rb
Class Method Summary collapse
Class Method Details
.format_phone(phone_string) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/models/concerns/has_phone.rb', line 5 def format_phone(phone_string) return '' if phone_string.nil? || phone_string.empty? phone_string = phone_string.gsub(/[^0-9]/, '') part1 = phone_string[0, 3] part2 = phone_string[3, 3] part3 = phone_string[6, 4] "#{part1} #{part2}-#{part3}" end |