Class: WorldBank::Country

Inherits:
Object
  • Object
show all
Defined in:
lib/world_bank/country.rb

Constant Summary collapse

COUNTRY_ALIASES =
[
  ['AW', 'ABW', 'aruba'],
  ['AF', 'AFG', 'afganistan'],
  ['AO', 'AGO', 'angola'],
  ['AI', 'AIA', 'anguilla'],
  ['AX', 'ALA', 'aland_islands'],
  ['AL', 'ALB', 'albania'],
  ['AD', 'AND', 'andorra'],
  ['AE', 'ARE', 'united_arab_emirates'],
  ['AR', 'ARG', 'argentina'],
  ['AM', 'ARM', 'armenia'],
  ['AS', 'ASM', 'american_samoa'],
  ['AQ', 'ATA', 'antarctica'],
  ['TF', 'ATF', 'french_southern_territories'],
  ['AG', 'ATG', 'antigua_and_barbuda'],
  ['AU', 'AUS', 'australia'],
  ['AT', 'AUT', 'austria'],
  ['AZ', 'AZE', 'azerbaijan'],
  ['BI', 'BDI', 'burundi'],
  ['BE', 'BEL', 'belgium'],
  ['BJ', 'BEN', 'benin'],
  ['BQ', 'BES', 'bonaire_saint_eustatius_and_saba'],
  ['BF', 'BFA', 'burkina_faso'],
  ['BD', 'BGD', 'bangladesh'],
  ['BG', 'BGR', 'bulgaria'],
  ['BH', 'BHR', 'bahrain'],
  ['BS', 'BHS', 'bahamas'],
  ['BA', 'BIH', 'bosnia_and_herzegovina'],
  ['BL', 'BLM', 'saint_barthelemy'],
  ['BY', 'BLR', 'belarus'],
  ['BZ', 'BLZ', 'belize'],
  ['BM', 'BMU', 'bermuda'],
  ['BO', 'BOL', 'plurinational_state_of_bolivia'],
  ['BR', 'BRA', 'brazil'],
  ['BB', 'BRB', 'barbados'],
  ['BN', 'BRN', 'brunei_darussalam'],
  ['BT', 'BTN', 'bhutan'],
  ['BV', 'BVT', 'bouvet_island'],
  ['BW', 'BWA', 'botswana'],
  ['CF', 'CAF', 'central_african_republic'],
  ['CA', 'CAN', 'canada'],
  ['CC', 'CCK', 'cocos_keeling_islands'],
  ['CH', 'CHE', 'switzerland'],
  ['CL', 'CHL', 'chile'],
  ['CN', 'CHN', 'china'],
  ['CI', 'CIV', 'cote_divoire'],
  ['CM', 'CMR', 'cameroon'],
  ['CD', 'COD', 'democratic_republic_of_the_congo'],
  ['CG', 'COG', 'congo'],
  ['CK', 'COK', 'cook_islands'],
  ['CO', 'COL', 'colombia'],
  ['KM', 'COM', 'comoros'],
  ['CV', 'CPV', 'cape_verde'],
  ['CR', 'CRI', 'costa_rica'],
  ['CU', 'CUB', 'cuba'],
  ['CW', 'CUW', 'curacao'],
  ['CX', 'CXR', 'christmas_island'],
  ['KY', 'CYM', 'cayman_islands'],
  ['CY', 'CYP', 'cyprus'],
  ['CZ', 'CZE', 'czech_republic'],
  ['DE', 'DEU', 'germany'],
  ['DJ', 'DJI', 'djibouti'],
  ['DM', 'DMA', 'dominca'],
  ['DK', 'DNK', 'denmark'],
  ['DO', 'DOM', 'dominican_republic'],
  ['DZ', 'DZA', 'algeria'],
  ['EC', 'ECU', 'ecuador'],
  ['EG', 'EGY', 'egypt'],
  ['ER', 'ERI', 'eritrea'],
  ['EH', 'ESH', 'western_sahara'],
  ['ES', 'ESP', 'spain'],
  ['EE', 'EST', 'estonia'],
  ['ET', 'ETH', 'ethiopia'],
  ['FI', 'FIN', 'finland'],
  ['FJ', 'FJI', 'fiji'],
  ['FK', 'FLK', 'falkland_islands_malvinas'],
  ['FR', 'FRA', 'france'],
  ['FO', 'FRO', 'faroe_islands'],
  ['FM', 'FSM', 'federated_states_of_micronesia'],
  ['GA', 'GAB', 'gabon'],
  ['GB', 'GBR', 'united_kingdom'],
  ['GE', 'GEO', 'georgia'],
  ['GG', 'GGY', 'guernsey'],
  ['GH', 'GHA', 'ghana'],
  ['GI', 'GIB', 'gibraltar'],
  ['GN', 'GIN', 'guinea'],
  ['GP', 'GLP', 'guadeloupe'],
  ['GM', 'GMB', 'gambia'],
  ['GW', 'GNB', 'guinea_bissau'],
  ['GQ', 'GNQ', 'equatorial_guinea'],
  ['GR', 'GRC', 'greece'],
  ['GD', 'GRD', 'grenada'],
  ['GL', 'GRL', 'greenland'],
  ['GT', 'GTM', 'guatemala'],
  ['GF', 'GUF', 'french_guiana'],
  ['GU', 'GUM', 'guam'],
  ['GY', 'GUY', 'guyana'],
  ['HK', 'HKG', 'hong_kong'],
  ['HM', 'HMD', 'heard_island_mcdonald_islands'],
  ['HN', 'HND', 'honduras'],
  ['HR', 'HRV', 'croatia'],
  ['HT', 'HTI', 'haiti'],
  ['HU', 'HUN', 'hungary'],
  ['ID', 'IDN', 'indonesia'],
  ['IM', 'IMN', 'isle_of_man'],
  ['IN', 'IND', 'india'],
  ['IO', 'IOT', 'british_indian_ocean_territory'],
  ['IE', 'IRL', 'ireland'],
  ['IR', 'IRN', 'islamic_republic_of_iran'],
  ['IQ', 'IRQ', 'iraq'],
  ['IS', 'ISL', 'iceland'],
  ['IL', 'ISR', 'israel'],
  ['IT', 'ITA', 'italy'],
  ['JM', 'JAM', 'jamaica'],
  ['JE', 'JEY', 'jersey'],
  ['JO', 'JOR', 'jordan'],
  ['JP', 'JPN', 'japan'],
  ['KZ', 'KAZ', 'kazakhstan'],
  ['KE', 'KEN', 'kenya'],
  ['KG', 'KGZ', 'kyrgyzstan'],
  ['KH', 'KHM', 'cambodia'],
  ['KI', 'KIR', 'kiribati'],
  ['KN', 'KNA', 'saint_kitts_and_nevis'],
  ['KR', 'KOR', 'republic_of_korea'],
  ['KW', 'KWT', 'kuwait'],
  ['LA', 'LAO', 'lao_peoples_democratic_republic'],
  ['LB', 'LBN', 'lebanon'],
  ['LR', 'LBR', 'liberia'],
  ['LY', 'LBY', 'libyan_arab_jamahiriya'],
  ['LC', 'LCA', 'saint_lucia'],
  ['LI', 'LIE', 'liechtenstein'],
  ['LK', 'LKA', 'sri_lanka'],
  ['LS', 'LSO', 'lesotho'],
  ['LT', 'LTU', 'lithuania'],
  ['LU', 'LUX', 'luxembourg'],
  ['LV', 'LVA', 'latvia'],
  ['MO', 'MAC', 'macao'],
  ['MF', 'MAF', 'saint_martin'],
  ['MA', 'MAR', 'morocco'],
  ['MC', 'MCO', 'monaco'],
  ['MD', 'MDA', 'republic_of_moldova'],
  ['MG', 'MDG', 'madagascar'],
  ['MV', 'MDV', 'maldives'],
  ['MX', 'MEX', 'mexico'],
  ['MH', 'MHL', 'marshall_islands'],
  ['MK', 'MKD', 'the_former_yugoslav_republic_of_macedonia'],
  ['ML', 'MLI', 'mali'],
  ['MT', 'MLT', 'malta'],
  ['MM', 'MMR', 'myanmar'],
  ['ME', 'MNE', 'montenegro'],
  ['MN', 'MNG', 'mongolia'],
  ['MP', 'MNP', 'northern_mariana_islands'],
  ['MZ', 'MOZ', 'mozambique'],
  ['MR', 'MRT', 'mauritania'],
  ['MS', 'MSR', 'montserrat'],
  ['MQ', 'MTQ', 'martinique'],
  ['MU', 'MUS', 'mauritius'],
  ['MW', 'MWI', 'malawi'],
  ['MY', 'MYS', 'malaysia'],
  ['YT', 'MYT', 'mayotte'],
  ['NA', 'NAM', 'namibia'],
  ['NC', 'NCL', 'new_caledonia'],
  ['NE', 'NER', 'niger'],
  ['NF', 'NFK', 'norfolk_island'],
  ['NG', 'NGA', 'nigeria'],
  ['NI', 'NIC', 'nicaragua'],
  ['NU', 'NIU', 'niue'],
  ['NL', 'NLD', 'netherlands'],
  ['NO', 'NOR', 'norway'],
  ['NP', 'NPL', 'nepal'],
  ['NR', 'NRU', 'nauru'],
  ['NZ', 'NZL', 'new_zealand'],
  ['OM', 'OMN', 'oman'],
  ['PK', 'PAK', 'pakistan'],
  ['PA', 'PAN', 'panama'],
  ['PN', 'PCN', 'pitcairn'],
  ['PE', 'PER', 'peru'],
  ['PH', 'PHL', 'philippines'],
  ['PW', 'PLW', 'palau'],
  ['PG', 'PNG', 'papua_new_guinea'],
  ['PL', 'POL', 'poland'],
  ['PR', 'PRI', 'puerto_rico'],
  ['KP', 'PRK', 'democratic_peoples_republic_of_korea'],
  ['PT', 'PRT', 'portugal'],
  ['PY', 'PRY', 'paraguay'],
  ['PS', 'PSE', 'occupied_palestinian_territory'],
  ['PF', 'PYF', 'french_polynesia'],
  ['QA', 'QAT', 'qatar'],
  ['RE', 'REU', 'reunion'],
  ['RO', 'ROU', 'romania'],
  ['RU', 'RUS', 'russian_federation'],
  ['RW', 'RWA', 'rwanda'],
  ['SA', 'SAU', 'saudi_arabia'],
  ['SD', 'SDN', 'sudan'],
  ['SN', 'SEN', 'senegal'],
  ['SG', 'SGP', 'singapore'],
  ['GS', 'SGS', 'south_georgia_and_the_south_sandwich_islands'],
  ['SH', 'SHN', 'saint_helena_ascension_and_tristan_da_cunha'],
  ['SJ', 'SJM', 'svalbard_and_jan_mayen'],
  ['SB', 'SLB', 'soloman_islands'],
  ['SL', 'SLE', 'sierra_leone'],
  ['SV', 'SLV', 'el_salvador'],
  ['SM', 'SMR', 'san_marino'],
  ['SO', 'SOM', 'somalia'],
  ['PM', 'SPM', 'saint_pierre_and_miquelon'],
  ['RS', 'SRB', 'serbia'],
  ['ST', 'STP', 'sao_tome_and_principe'],
  ['SR', 'SUR', 'suriname'],
  ['SK', 'SVK', 'slovakia'],
  ['SI', 'SVN', 'slovenia'],
  ['SE', 'SWE', 'sweden'],
  ['SZ', 'SWZ', 'swaziland'],
  ['SX', 'SXM', 'sint_maarten'],
  ['SC', 'SYC', 'seychelles'],
  ['SY', 'SYR', 'syrian_arab_republic'],
  ['TC', 'TCA', 'turks_caicos_islands'],
  ['TD', 'TCD', 'chad'],
  ['TG', 'TGO', 'togo'],
  ['TH', 'THA', 'thailand'],
  ['TJ', 'TJK', 'tajikistan'],
  ['TK', 'TKL', 'tokelau'],
  ['TM', 'TKM', 'turkmenistan'],
  ['TL', 'TLS', 'timor_leste'],
  ['TO', 'TON', 'tonga'],
  ['TT', 'TTO', 'trinidad_and_tobago'],
  ['TN', 'TUN', 'tunisia'],
  ['TR', 'TUR', 'turkey'],
  ['TU', 'TUV', 'tuvalu'],
  ['TW', 'TWN', 'taiwan_provice_of_china'],
  ['TZ', 'TZA', 'united_republic_of_tanzania'],
  ['UG', 'UGA', 'uganda'],
  ['UA', 'UKR', 'ukraine'],
  ['UM', 'UMI', 'united_states_minor_outlying_islands'],
  ['UY', 'URY', 'uruguay'],
  ['US', 'USA', 'united_states_of_america'],
  ['UZ', 'UZB', 'uzbekistan'],
  ['VC', 'VCT', 'saint_vincent_and_the_grenadines'],
  ['VE', 'VEN', 'bolivarian_republic_of_venezuela'],
  ['VG', 'VGB', 'british_virgin_islands'],
  ['VI', 'VIR', 'us_virgin_islands'],
  ['VN', 'VNM', 'viet_nam'],
  ['VU', 'VUT', 'vanuatu'],
  ['WF', 'WLF', 'wallis_and_futuna'],
  ['WS', 'WSM', 'samoa'],
  ['YE', 'YEM', 'yemen'],
  ['ZA', 'ZAF', 'south_africa'],
  ['ZM', 'ZMB', 'zambia'],
  ['ZW', 'ZWE', 'zimbabwe']
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ Country

Returns a new instance of Country.



319
320
321
322
323
324
325
326
327
328
329
# File 'lib/world_bank/country.rb', line 319

def initialize(values={})
  @raw = values
  @name = values['name']
  @iso2_code = values['iso2Code']
  @iso3_code = values['id']
  @region = WorldBank::Region.new(values['region'])
  @income_level = WorldBank::IncomeLevel.new(values['incomeLevel'])
  @lending_type = WorldBank::LendingType.new(values['lendingType'])
  @capital = values['capitalCity']
  @type = 'countries'
end

Instance Attribute Details

#capitalObject (readonly)

Returns the value of attribute capital.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def capital
  @capital
end

#income_levelObject (readonly)

Returns the value of attribute income_level.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def income_level
  @income_level
end

#iso2_codeObject (readonly)

Returns the value of attribute iso2_code.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def iso2_code
  @iso2_code
end

#iso3_codeObject (readonly)

Returns the value of attribute iso3_code.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def iso3_code
  @iso3_code
end

#lending_typeObject (readonly)

Returns the value of attribute lending_type.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def lending_type
  @lending_type
end

#nameObject (readonly)

Returns the value of attribute name.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def raw
  @raw
end

#regionObject (readonly)

Returns the value of attribute region.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def region
  @region
end

#typeObject (readonly)

Returns the value of attribute type.



255
256
257
# File 'lib/world_bank/country.rb', line 255

def type
  @type
end

Class Method Details

.allObject



309
310
311
# File 'lib/world_bank/country.rb', line 309

def self.all
  find('all')
end

.countryObject



297
298
299
# File 'lib/world_bank/country.rb', line 297

def self.country
  find('all').country(arg)
end

.country_aliasesObject



257
258
259
# File 'lib/world_bank/country.rb', line 257

def self.country_aliases
  COUNTRY_ALIASES
end

.fetch(arg) ⇒ Object



305
306
307
# File 'lib/world_bank/country.rb', line 305

def self.fetch(arg)
  find(arg).fetch
end

.find(id) ⇒ Object



313
314
315
316
317
# File 'lib/world_bank/country.rb', line 313

def self.find(id)
  id = normalize_id id
  id = ensure_id id unless id =~ /all/
  WorldBank::ParamQuery.new('countries', id, self)
end

.format(arg) ⇒ Object



261
262
263
# File 'lib/world_bank/country.rb', line 261

def self.format(arg)
  find('all').format(arg)
end

.id(arg) ⇒ Object



265
266
267
# File 'lib/world_bank/country.rb', line 265

def self.id(arg)
  find('all').id(arg)
end

.income_level(arg) ⇒ Object



285
286
287
# File 'lib/world_bank/country.rb', line 285

def self.income_level(arg)
  find('all').income_level(arg)
end

.indicators(arg) ⇒ Object



301
302
303
# File 'lib/world_bank/country.rb', line 301

def self.indicators(arg)
  find('all').indicator(arg)
end

.language(arg) ⇒ Object



281
282
283
# File 'lib/world_bank/country.rb', line 281

def self.language(arg)
  find('all').language(arg)
end

.lending_type(arg) ⇒ Object



289
290
291
# File 'lib/world_bank/country.rb', line 289

def self.lending_type(arg)
  find('all').lending_type(arg)
end

.most_recent_values(arg) ⇒ Object



269
270
271
# File 'lib/world_bank/country.rb', line 269

def self.most_recent_values(arg)
  find('all').most_recent_values(arg)
end

.page(arg) ⇒ Object



273
274
275
# File 'lib/world_bank/country.rb', line 273

def self.page(arg)
  find('all').page(arg)
end

.per_pageObject



277
278
279
# File 'lib/world_bank/country.rb', line 277

def self.per_page
  find('all').per_page(arg)
end

.region(arg) ⇒ Object



293
294
295
# File 'lib/world_bank/country.rb', line 293

def self.region(arg)
  find('all').region(arg)
end