class ActiveMerchant::CountryCode
Attributes
format[R]
value[R]
Public Class Methods
new(value)
click to toggle source
# File lib/active_utils/common/country.rb, line 13 def initialize(value) @value = value.to_s.upcase detect_format end
Public Instance Methods
to_s()
click to toggle source
# File lib/active_utils/common/country.rb, line 18 def to_s value end
Private Instance Methods
detect_format()
click to toggle source
# File lib/active_utils/common/country.rb, line 24 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