class ActiveMerchant::CountryCode

Attributes

format[R]
value[R]

Public Class Methods

new(value) click to toggle source
# File lib/active_merchant/country.rb, line 12
def initialize(value)
  @value = value.to_s.upcase
  detect_format
end

Public Instance Methods

to_s() click to toggle source
# File lib/active_merchant/country.rb, line 17
def to_s
  value
end

Private Instance Methods

detect_format() click to toggle source
# File lib/active_merchant/country.rb, line 23
def detect_format
  case @value
  when /^[[:alpha:]]{2}$/
    @format = :alpha2
  when /^[[:alpha:]]{3}$/
    @format = :alpha3
  when /^[[:digit:]]{3}$/
    @format = :numeric
  else
    raise CountryCodeFormatError, "The country code is not formatted correctly #{@value}"
  end
end