class ISO3166::Country
:reek:TooManyMethods
def <=>(other)
def <=>(other) to_s <=> other.to_s end
def ==(other)
:reek:FeatureEnvy
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?
+true+ if this country is a member of the European Economic Area.
def in_eea? data['eea_member'].nil? ? false : data['eea_member'] end
def in_esm?
+true+ if this country is a member of the European Single Market.
def in_esm? data['esm_member'].nil? ? in_eea? : data['esm_member'] end
def in_eu?
+true+ if this country is a member of the European Union.
def in_eu? data['eu_member'].nil? ? false : data['eu_member'] end
def in_eu_vat?
+true+ if this country is a member of the EU VAT Area.
def in_eu_vat? data['euvat_member'].nil? ? in_eu? : data['euvat_member'] end
def in_g20?
+true+ if this country is a member of the G20.
def in_g20? data['g20_member'].nil? ? false : data['g20_member'] end
def in_g7?
+true+ if this country is a member of the G7.
def in_g7? data['g7_member'].nil? ? false : data['g7_member'] end
def in_un?
+true+ if this country is a member of the United Nations.
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)
Convert an +ISO3166::Country+ to the data that is stored by Mongoid.
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) locale = locale.to_sym if locale.is_a?(String) locale = locale.downcase if locale.match?(/[A-Z]/) data['translations'][locale] 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