Module: ISO3166

Defined in:
lib/countries/data.rb,
lib/countries/country.rb,
lib/countries/mongoid.rb,
lib/countries/structure.rb,
lib/countries/timezones.rb,
lib/countries/subdivision.rb,
lib/countries/translations.rb,
lib/countries/configuration.rb,
lib/countries/country/emoji.rb,
lib/countries/data/locales_methods.rb,
lib/countries/country/class_methods.rb,
lib/countries/country/finder_methods.rb,
lib/countries/country/currency_methods.rb,
lib/countries/data/subdivision_methods.rb,
lib/countries/country/conversion_methods.rb,
lib/countries/country/country_subdivision_methods.rb

Defined Under Namespace

Modules: ConversionMethods, CountryClassMethods, CountryCurrencyMethods, CountryFinderMethods, CountrySubdivisionMethods, Emoji, LocalesMethods, SubdivisionMethods, TimezoneExtensions Classes: Configuration, Country, Data, Subdivision, Translations

Constant Summary collapse

DEFAULT_COUNTRY_HASH =
{
  'address_format' => nil,
  'alpha2' => nil,
  'alpha3' => nil,
  'continent' => nil,
  'country_code' => nil,
  'currency_code' => nil,
  'distance_unit' => nil,
  'gec' => nil,
  'geo' => {
    'latitude' => nil,
    'longitude' => nil,
    'max_latitude' => nil,
    'max_longitude' => nil,
    'min_latitude' => nil,
    'min_longitude' => nil,
    'bounds' => {
      'northeast' => {
        'lat' => nil,
        'lng' => nil
      },
      'southwest' => {
        'lat' => nil,
        'lng' => nil
      }
    }
  },
  'international_prefix' => nil,
  'ioc' => nil,
  'iso_long_name' => nil,
  'iso_short_name' => nil,
  'national_destination_code_lengths' => [],
  'national_number_lengths' => [],
  'national_prefix' => nil,
  'nanp_prefix' => nil,
  'nationality' => nil,
  'number' => nil,
  'languages_official' => [],
  'languages_spoken' => [],
  'translations' => {},
  'postal_code' => nil,
  'postal_code_format' => nil,
  'region' => nil,
  'unofficial_names' => [],
  'start_of_week' => 'monday',
  'subregion' => nil,
  'un_locode' => nil,
  'vat_rates' => {
    'standard' => nil,
    'reduced' => [nil, nil],
    'super_reduced' => nil,
    'parking' => nil
  },
  'world_region' => nil
}.freeze
DEFAULT_SUBDIVISION_HASH =
{
  'name' => nil,
  'unofficial_names' => [],
  'translations' => {},
  'geo' => {
    'latitude' => nil,
    'longitude' => nil,
    'max_latitude' => nil,
    'max_longitude' => nil,
    'min_latitude' => nil,
    'min_longitude' => nil
  }
}.freeze
UNSEARCHABLE_METHODS =
[:translations].freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



8
9
10
# File 'lib/countries/configuration.rb', line 8

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



17
18
19
# File 'lib/countries/configuration.rb', line 17

def self.configure
  yield(configuration)
end

.Country(country_data_or_country) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/countries/country/class_methods.rb', line 8

def self.Country(country_data_or_country)
  case country_data_or_country
  when ISO3166::Country
    country_data_or_country
  when String, Symbol
    ISO3166::Country.search(country_data_or_country)
  else
    raise TypeError, "can't convert #{country_data_or_country.class.name} into ISO3166::Country"
  end
end

.resetObject



12
13
14
15
# File 'lib/countries/configuration.rb', line 12

def self.reset
  @configuration = Configuration.new
  Data.reset
end