Module: Phonelib::PhoneAnalyzer

Includes:
PhoneAnalyzerHelper
Included in:
Phone
Defined in:
lib/phonelib/phone_analyzer.rb

Constant Summary collapse

NOT_FOR_CHECK =

array of types not included for validation check in cycle

[:general_desc, :fixed_line, :mobile, :fixed_or_mobile]

Instance Method Summary collapse

Instance Method Details

#analyze(phone, passed_country) ⇒ Object

parses provided phone if it is valid for country data and returns result of analyze

Attributes

  • phone - Phone number for parsing

  • passed_country - Country provided for parsing. Must be ISO code of country (2 letters) like ‘US’, ‘us’ or :us for United States



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/phonelib/phone_analyzer.rb', line 18

def analyze(phone, passed_country)
  countries = country_or_default_country passed_country

  return analyze_single_country(phone, countries.first, passed_country) if countries.size == 1

  results = {}
  countries.map do |country|
    results.merge! analyze_single_country(phone, country, passed_country)
  end

  pick_results(results)
end