lib/phonelib/phone_analyzer_helper.rb in phonelib-0.6.58 vs lib/phonelib/phone_analyzer_helper.rb in phonelib-0.7.0
- old
+ new
@@ -1,10 +1,18 @@
module Phonelib
# @private helper methods for analyser
module PhoneAnalyzerHelper
private
+ def decorate_analyze_result(result)
+ if result.size == 1
+ result
+ else
+ Hash[result.take(1)]
+ end
+ end
+
def original_starts_with_plus?
original_s[0] == Core::PLUS_SIGN
end
# converts symbols in phone to numbers
@@ -88,10 +96,14 @@
# ==== Attributes
#
# * +country+ - country passed for parsing
def country_or_default_country(country)
country ||= (original_starts_with_plus? ? nil : Phonelib.default_country)
- country && country.to_s.upcase
+ if country.is_a?(Array)
+ country.compact.map { |e| e.to_s.upcase }
+ else
+ [country && country.to_s.upcase]
+ end
end
# constructs full regex for phone validation for provided phone data
# (international prefix, country code, national prefix, valid number)
#