class ActiveUtils::CountryCode
Attributes
Public Class Methods
Source
# File lib/active_utils/country.rb, line 13 def initialize(value) @value = value.to_s.upcase detect_format end
Public Instance Methods
Private Instance Methods
Source
# File lib/active_utils/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