Module: Valvat::Utils

Defined in:
lib/valvat/utils.rb

Constant Summary

EU_COUNTRIES =
%w(AT
COUNTRY_PATTERN =
/\A([A-Z]{2})(.+)\Z/

Class Method Summary (collapse)

Class Method Details

+ (Object) normalize(vat)



15
16
17
# File 'lib/valvat/utils.rb', line 15

def self.normalize(vat)
  vat.upcase.gsub(/\A\s+|\s+\Z/, "")
end

+ (Object) split(vat)



7
8
9
10
11
12
13
# File 'lib/valvat/utils.rb', line 7

def self.split(vat)
  COUNTRY_PATTERN =~ vat 
  result = [$1, $2]
  result[0] = "GR" if result[0] == "EL"
  return [nil, nil] unless EU_COUNTRIES.include?(result[0])
  result
end