module Phonejack::ClassMethods
Attributes
default_format_pattern[R]
default_format_string[RW]
override_file[RW]
Public Instance Methods
default_format_pattern=(format_string)
click to toggle source
# File lib/phonejack/class_methods.rb, line 6 def default_format_pattern=(format_string) @default_format_pattern = Regexp.new(format_string) end
detect_country(number)
click to toggle source
# File lib/phonejack/class_methods.rb, line 26 def detect_country(number) sanitized_number = sanitize(number) detected_country = Country.all_countries.detect do |country| sanitized_number.start_with?(country.country_code) && valid?(sanitized_number, country.country_id) end detected_country.country_id.to_sym if detected_country end
generate_override_file(file)
click to toggle source
generates binary file from xml that user gives us
# File lib/phonejack/class_methods.rb, line 36 def generate_override_file(file) DataImporter.new(file, override: true).import! end
invalid?(*args)
click to toggle source
# File lib/phonejack/class_methods.rb, line 18 def invalid?(*args) !valid?(*args) end
parse(number, country = detect_country(number))
click to toggle source
# File lib/phonejack/class_methods.rb, line 10 def parse(number, country = detect_country(number)) Phonejack::Number.new(sanitize(number), country) end
sanitize(input_number)
click to toggle source
# File lib/phonejack/class_methods.rb, line 22 def sanitize(input_number) input_number.to_s.gsub(/\D/, '') end
valid?(number, country = detect_country(number), keys = [])
click to toggle source
# File lib/phonejack/class_methods.rb, line 14 def valid?(number, country = detect_country(number), keys = []) parse(number, country).valid?(keys) end