Module: Phonelib::PhoneAnalyzer
- Included in:
- Phone
- Defined in:
- lib/phonelib/phone_analyzer.rb
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
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/phonelib/phone_analyzer.rb', line 15 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? result = detect_and_parse phone end result end |