Module: Countries::PhoneNumbers
- Includes:
- Extensions, Formatters
- Defined in:
- lib/countries/phone_numbers.rb,
lib/countries/phone_numbers/version.rb
Defined Under Namespace
Modules: Extensions, Formatters Classes: Detector, DetectorFactory, OneOfDetector, StartWithDetector
Constant Summary collapse
- DATA_FILE =
File.join( File.dirname(__FILE__), 'phone_numbers', 'detectors.yaml' )
- VERSION =
"1.0.3"
Class Method Summary collapse
-
.shared_country_codes ⇒ Object
Find all countries with shared country codes.
-
.unresolved_country_codes ⇒ Object
Find all countries with shared country codes and do not have a dedicated detector.
Methods included from Formatters
Methods included from Extensions
Class Method Details
.shared_country_codes ⇒ Object
Find all countries with shared country codes.
26 27 28 29 30 31 |
# File 'lib/countries/phone_numbers.rb', line 26 def self.shared_country_codes codes = Country.all.map { |cc| Country[cc[1]].country_code }.uniq shared = codes.each_with_object({}){ |cc,h| h[cc] = Country.find_all_countries_by_country_code(cc) } shared.reject!{ |key,entry| entry.nil? or entry.count <= 1 } shared.each{ |cc,countries| shared[cc] = countries.map{ |c| c.name } } end |
.unresolved_country_codes ⇒ Object
Find all countries with shared country codes and do not have a dedicated detector.
35 36 37 |
# File 'lib/countries/phone_numbers.rb', line 35 def self.unresolved_country_codes shared_country_codes.reject{ |key,value| self.phone_number_detector_factory.detector_for? key or key == '' } end |