class ISO3166::Country
def <=>(other)
def <=>(other) to_s <=> other.to_s end
def ==(other)
def ==(other) other.respond_to?(:alpha2) && other.alpha2 == alpha2 end
def common_name
-
(String)
- the “common name” of this Country in English.
def common_name ISO3166.configuration.locales = ISO3166.configuration.locales.append(:en).uniq translation('en') end
def demongoize(alpha2)
def demongoize(alpha2) new(alpha2) end
def eql?(other)
def eql?(other) self == other end
def evolve(country)
def evolve(country) mongoize(country) end
def gdpr_compliant?
def gdpr_compliant? data['eea_member'] || alpha2 == 'GB' end
def hash
def hash [alpha2, alpha3].hash end
def in_eea?
def in_eea? data['eea_member'].nil? ? false : data['eea_member'] end
def in_esm?
def in_esm? data['esm_member'].nil? ? in_eea? : data['esm_member'] end
def in_eu?
def in_eu? data['eu_member'].nil? ? false : data['eu_member'] end
def in_eu_vat?
def in_eu_vat? data['euvat_member'].nil? ? in_eu? : data['euvat_member'] end
def in_g20?
def in_g20? data['g20_member'].nil? ? false : data['g20_member'] end
def in_g7?
def in_g7? data['g7_member'].nil? ? false : data['g7_member'] end
def in_un?
def in_un? data['un_member'].nil? ? false : data['un_member'] end
def initialize(country_data)
def initialize(country_data) @country_data_or_code = country_data reload end
def local_name
-
(String)
- The name for this Country, in this Country's locale.
def local_name @local_name ||= local_names.first end
def local_names
-
(Array
- The list of names for this Country, in this Country's locales.)
def local_names ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq reload @local_names ||= languages.map { |language| translations[language] } end
def mongoize
def mongoize ISO3166::Country.mongoize(self) end
def mongoize(country)
def mongoize(country) if country.is_a?(self) && !country.data.nil? country.alpha2 elsif send(:valid_alpha2?, country) new(country).alpha2 end end
def postal_code_format
-
(String)
- The regex for valid postal codes in this Country
def postal_code_format "\\A#{data['postal_code_format']}\\Z" if postal_code end
def reload
def reload @data = if @country_data_or_code.is_a?(Hash) @country_data_or_code else ISO3166::Data.new(@country_data_or_code).call end end
def to_s
def to_s data['iso_short_name'] end
def translated_names
-
(Array
- the list of names for this Country in all loaded locales.)
def translated_names data['translations'].values.compact end
def translation(locale = 'en')
-
(String)
- the name of this Country in the selected locale.
Parameters:
-
locale
(String
) -- The locale to use for translations.
def translation(locale = 'en') data['translations'][locale.to_s.downcase] end
def valid?
def valid? !(data.nil? || data.empty?) end
def valid_alpha2?(country)
def valid_alpha2?(country) country.is_a?(String) && !ISO3166::Country.new(country).nil? end