Module: Phonelib::PhoneAnalyzer
Overview
phone analyzing methods module
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
-
#analyze(phone, passed_country) ⇒ Object
parses provided phone if it is valid for country data and returns result of analyze.
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 |
# File 'lib/phonelib/phone_analyzer.rb', line 18 def analyze(phone, passed_country) country = country_or_default_country passed_country result = try_to_parse_single_country(phone, country) # if previous parsing failed, trying for all countries if result.nil? || result.empty? || result.values.first[:valid].empty? detected = detect_and_parse phone result = detected.empty? ? result || {} : detected end result end |