2018-10-22 11:44:36 -04:00
|
|
|
# PhoneNumber class
|
2018-09-21 11:49:59 -05:00
|
|
|
class PhoneNumber
|
|
|
|
def self.clean(number)
|
2018-10-22 11:44:36 -04:00
|
|
|
number = number.gsub(/\D/, '').sub(/^[01]/, '')
|
|
|
|
return nil if number.length != 10 || %w[0 1].include?(number[3])
|
2018-09-21 11:49:59 -05:00
|
|
|
|
2018-10-22 11:44:36 -04:00
|
|
|
number
|
2018-09-21 11:49:59 -05:00
|
|
|
end
|
|
|
|
end
|