lib/phony_rails.rb in phony_rails-0.0.5 vs lib/phony_rails.rb in phony_rails-0.0.6

- old
+ new

@@ -21,12 +21,14 @@ # This method requires a country_code attribute (eg. NL) and phone_number to be set. # Options: # :country_code => The country code we should use. # :default_country_code => Some fallback code (eg. 'NL') that can be used as default (comes from phony_normalize_numbers method). + # This idea came from: + # http://www.redguava.com.au/2011/06/rails-convert-phone-numbers-to-international-format-for-sms/ def self.normalize_number(number, options = {}) return if number.blank? - number = Phony.normalize(number) # TODO: Catch errors + number = Phony::CountryCodes.instance.clean(number) # Strips weird stuff from the number if country_number = COUNTRY_NUMBER[options[:country_code] || options[:default_country_code]] # Add country_number if missing number = "#{country_number}#{number}" if not number =~ /^(00|\+)?#{country_number}/ end number = Phony.normalize(number) \ No newline at end of file