Module: Philiprehberger::Phone::PhoneTypeDetection

Included in:
PhoneNumber
Defined in:
lib/philiprehberger/phone/phone_type.rb

Instance Method Summary collapse

Instance Method Details

#phone_typeObject



204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/philiprehberger/phone/phone_type.rb', line 204

def phone_type
  return :unknown unless @country

  patterns = PHONE_TYPE_PATTERNS[@country]
  return :unknown unless patterns

  %i[toll_free premium mobile landline].each do |type|
    pattern = patterns[type]
    return type if pattern&.match?(@national)
  end

  :unknown
end