country_code 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/country_code.rb +21 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61b61660f280378b1b98b605a8671356390d1181
4
+ data.tar.gz: 5ad86c002a1371b3f22c08c8f34dd3e32ad6e6de
5
+ SHA512:
6
+ metadata.gz: abd0601605f15bd02d1364d425889a898d95feb01f3836546aefbc3201150cca986f33d6bb566dbb7b5ab67a175dade734e982b9f45b5330545a4e22605dfc96
7
+ data.tar.gz: 2eb7f6824b8f7dc6adf67e203798926b9210e74727101a5a2a59e972881e498fc154701431b2304f024033110d577abb1dcd9acdbef321e941ccef0c47dac39c
@@ -0,0 +1,21 @@
1
+ class CountryCode
2
+
3
+ def self.find(country_name, alpha)
4
+ if !self.countries[country_name.downcase].nil?
5
+ self.countries[country_name.downcase][alpha.to_s]
6
+ else
7
+ "Country name is not present. Sorry !"
8
+ end
9
+ end
10
+
11
+ private
12
+ def self.countries
13
+ hash_value = {"Afghanistan"=>{"2"=>"AF", "3"=>"AFG"},"Albania"=>{"2"=>"AL", "3"=>"ALB"},"Algeria"=>{"2"=>"DZ", "3"=>"DZA"},"American Samoa"=>{"2"=>"AS", "3"=>"ASM"},"Andorra"=>{"2"=>"AD", "3"=>"AND"},"Angola"=>{"2"=>"AO", "3"=>"AGO"},"Anguilla"=>{"2"=>"AIA", "3"=>"ALB"},"Antarctica"=>{"2"=>"AQ", "3"=>"ARG"},"Antigua and Barbuda"=>{"2"=>"AG", "3"=>"ATG"},"Argentina"=>{"2"=>"AR", "3"=>"ALB"},"Armenia"=>{"2"=>"AM", "3"=>"ARM"},"Aruba"=>{"2"=>"AW", "3"=>"ABW"},"Australia"=>{"2"=>"AU", "3"=>"AUS"},"Austria"=>{"2"=>"AT", "3"=>"AUT"},"Azerbaijan"=>{"2"=>"AZ", "3"=>"AZE"},"Bahamas"=>{"2"=>"BS", "3"=>"BHS"},"Bahrain"=>{"2"=>"BH", "3"=>"BHR"},"Bangladesh"=>{"2"=>"BD", "3"=>"BGD"},"Barbados"=>{"2"=>"BB", "3"=>"BRB"},"Belarus"=>{"2"=>"BY", "3"=>"BLR"},"Belgium"=>{"2"=>"BE", "3"=>"BEL"},"Belize"=>{"2"=>"BZ", "3"=>"BLZ"},"Benin"=>{"2"=>"BJ", "3"=>"BEN"},"Bermuda"=>{"2"=>"BM", "3"=>"BMU"},"Bhutan"=>{"2"=>"BT", "3"=>"BIH"},"Bolivia"=>{"2"=>"BO", "3"=>"BOL"},"Bosnia and Herzegovina"=>{"2"=>"BA", "3"=>"ALB"},"Botswana"=>{"2"=>"BW", "3"=>"BWA"},"Brazil"=>{"2"=>"BR", "3"=>"BRA"},"British Indian Ocean Territory"=>{"2"=>"IO", "3"=>"IOT"},"British Virgin Islands"=>{"2"=>"VG", "3"=>"VGB"},"Brunei"=>{"2"=>"BN", "3"=>"BRN"},"Bulgaria"=>{"2"=>"BG", "3"=>"BGR"},"Burkina Faso"=>{"2"=>"BF", "3"=>"BFA"},"Burma"=>{"2"=>"MM", "3"=>"MMR"},"Myanmar"=>{"2"=>"MM", "3"=>"MMR"},"Burundi"=>{"2"=>"BI", "3"=>"BDI"},"Cambodia"=>{"2"=>"KH", "3"=>"KHM"},"Cameroon"=>{"2"=>"CM", "3"=>"CMR"},"Canada"=>{"2"=>"CA", "3"=>"CAN"},"Cape Verde"=>{"2"=>"CV", "3"=>"CPV"},"Cayman Islands"=>{"2"=>"KY", "3"=>"CYM"},"Central African Republic"=>{"2"=>"CF", "3"=>"CAF"},"Chad"=>{"2"=>"TD", "3"=>"TCD"},"Chile"=>{"2"=>"CL", "3"=>"CHL"},"China"=>{"2"=>"CN", "3"=>"CHN"},"Christmas Island"=>{"2"=>"CX", "3"=>"CXR"},"Cocos Islands"=>{"2"=>"CC", "3"=>"CCK"},"Keeling Islands"=>{"2"=>"CC", "3"=>"CCK"},"Colombia"=>{"2"=>"CO", "3"=>"COL"},"Comoros"=>{"2"=>"KM", "3"=>"COM"},"Cook Islands"=>{"2"=>"CK", "3"=>"COK"},"Costa Rica"=>{"2"=>"CR", "3"=>"CRC"},"Croatia"=>{"2"=>"HR", "3"=>"HRV"},"Cuba"=>{"2"=>"CU", "3"=>"CUB"},"Cyprus"=>{"2"=>"CY", "3"=>"CYP"},"Czech Republic"=>{"2"=>"CZ", "3"=>"CZE"},"Democratic Republic of the Congo"=>{"2"=>"CD", "3"=>"COD"},"Denmark"=>{"2"=>"DK", "3"=>"DNK"},"Djibouti"=>{"2"=>"DJ", "3"=>"DJI"},"Dominica"=>{"2"=>"DM", "3"=>"DMA"},"Dominican Republic"=>{"2"=>"DO", "3"=>"DOM"},"Ecuador"=>{"2"=>"EC", "3"=>"ECU"},"Egypt"=>{"2"=>"EG", "3"=>"EGY"},"El Salvador"=>{"2"=>"SV", "3"=>"SLV"},"Equatorial Guinea"=>{"2"=>"GQ", "3"=>"GNQ"},"Eritrea"=>{"2"=>"ER", "3"=>"ERI"},"Estonia"=>{"2"=>"EE", "3"=>"EST"},"Ethiopia"=>{"2"=>"ET", "3"=>"ETH"},"Falkland Islands"=>{"2"=>"FK", "3"=>"FLK"},"Faroe Islands"=>{"2"=>"FO", "3"=>"FRO"},"Fiji"=>{"2"=>"FJ", "3"=>"FJI"},"Finland"=>{"2"=>"FI", "3"=>"FIN"},"France"=>{"2"=>"FR", "3"=>"FRA"},"French Polynesia"=>{"2"=>"PF", "3"=>"PYF"},"Gabon"=>{"2"=>"GA", "3"=>"GAB"},"Gambia"=>{"2"=>"GM", "3"=>"GMB"},"Gaza Strip"=>{"2"=>"", "3"=>""},"Georgia"=>{"2"=>"GE", "3"=>"GEO"},"Germany"=>{"2"=>"DE", "3"=>"DEU"},"Ghana"=>{"2"=>"GH", "3"=>"GHA"},"Gibraltar"=>{"2"=>"GI", "3"=>"GIB"},"Greece"=>{"2"=>"GR", "3"=>"GRC"},"Greenland"=>{"2"=>"GL", "3"=>"GRL"},"Grenada"=>{"2"=>"GD", "3"=>"GRD"},"Guam"=>{"2"=>"GU", "3"=>"GUM"},"Guatemala"=>{"2"=>"GT", "3"=>"GTM"},"Guinea"=>{"2"=>"GN", "3"=>"GIN"},"Guinea-Bissau"=>{"2"=>"GW", "3"=>"GNB"},"Guyana"=>{"2"=>"GY", "3"=>"GUY"},"Haiti"=>{"2"=>"HT", "3"=>"HTI"},"Holy See"=>{"2"=>"VA", "3"=>"VAT"},"Vatican City"=>{"2"=>"VA", "3"=>"VAT"},"Honduras"=>{"2"=>"HN", "3"=>"HND"},"Hong Kong"=>{"2"=>"HK", "3"=>"HKG"},"Hungary"=>{"2"=>"HU", "3"=>"HUN"},"Iceland"=>{"2"=>"IS", "3"=>"IS"},"India"=>{"2"=>"IN", "3"=>"IND"},"Indonesia"=>{"2"=>"ID", "3"=>"IDN"},"Iran"=>{"2"=>"IR", "3"=>"IRN"},"Iraq"=>{"2"=>"IQ", "3"=>"IRQ"},"Ireland"=>{"2"=>"IE", "3"=>"IRL"},"Isle of Man"=>{"2"=>"IM", "3"=>"IMN"},"Israel"=>{"2"=>"IL", "3"=>"ISR"},"Italy"=>{"2"=>"IT", "3"=>"ISR"},"Ivory Coast"=>{"2"=>"CI", "3"=>"CIV"},"Jamaica"=>{"2"=>"JM", "3"=>"JAM"},"Japan"=>{"2"=>"JP", "3"=>"JPN"},"Jersey"=>{"2"=>"JE", "3"=>"JEY"},"Jordan"=>{"2"=>"JO", "3"=>"JOR"},"Kazakhstan"=>{"2"=>"KZ", "3"=>"KAZ"},"Kenya"=>{"2"=>"KE", "3"=>"KEN"},"Kiribati"=>{"2"=>"KI", "3"=>"KIR"},"Kosovo"=>{"2"=>"", "3"=>""},"Kuwait"=>{"2"=>"KW", "3"=>"KWT"},"Kyrgyzstan"=>{"2"=>"KG", "3"=>"KGZ"},"Laos"=>{"2"=>"LA", "3"=>"LAO"},"Latvia"=>{"2"=>"LV", "3"=>"LVA"},"Lebanon"=>{"2"=>"LB", "3"=>"LBN"},"Lesotho"=>{"2"=>"LS", "3"=>"LSO"},"Liberia"=>{"2"=>"LR", "3"=>"LBR"},"Libya"=>{"2"=>"LY", "3"=>"LBY"},"Liechtenstein"=>{"2"=>"LI", "3"=>"LIE"},"Lithuania"=>{"2"=>"LT", "3"=>"LTU"},"Luxembourg"=>{"2"=>"LU", "3"=>"LUX"},"Macau"=>{"2"=>"MO", "3"=>"MAC"},"Macedonia"=>{"2"=>"MK", "3"=>"MKD"},"Madagascar"=>{"2"=>"MG", "3"=>"MDG"},"Malawi"=>{"2"=>"MW", "3"=>"MWI"},"Malaysia"=>{"2"=>"MY", "3"=>"MYS"},"Maldives"=>{"2"=>"MV", "3"=>"MDV"},"Mali"=>{"2"=>"ML", "3"=>"MLI"},"Malta"=>{"2"=>"MT", "3"=>"MLT"},"Marshall Islands"=>{"2"=>"MH", "3"=>"MHL"},"Mauritania"=>{"2"=>"MR", "3"=>"MRT"},"Mauritius"=>{"2"=>"MU", "3"=>"MUS"},"Mayotte"=>{"2"=>"YT", "3"=>"MYT"},"Mexico"=>{"2"=>"MX", "3"=>"MEX"},"Micronesia"=>{"2"=>"FM", "3"=>"FSM"},"Moldova"=>{"2"=>"MD", "3"=>"MDA"},"Monaco"=>{"2"=>"MC", "3"=>"MCO"},"Mongolia"=>{"2"=>"MN", "3"=>"MNG"},"Montenegro"=>{"2"=>"ME", "3"=>"MNE"},"Montserrat"=>{"2"=>"MS", "3"=>"MSR"},"Morocco"=>{"2"=>"MA", "3"=>"MAR"},"Mozambique"=>{"2"=>"MZ", "3"=>"MOZ"},"Namibia"=>{"2"=>"NA", "3"=>"NAM"},"Nauru"=>{"2"=>"NR", "3"=>"NRU"},"Nepal"=>{"2"=>"NP", "3"=>"NPL"},"Netherlands"=>{"2"=>"NL", "3"=>"NLD"},"Netherlands Antilles"=>{"2"=>"AN", "3"=>"ANT"},"New Caledonia"=>{"2"=>"NC", "3"=>"NCL"},"New Zealand"=>{"2"=>"NZ", "3"=>"NZL"},"Nicaragua"=>{"2"=>"NI", "3"=>"NIC"},"Niger"=>{"2"=>"NE", "3"=>"NER"},"Nigeria"=>{"2"=>"NG", "3"=>"NGA"},"Niue"=>{"2"=>"NU", "3"=>"NIU"},"Norfolk Island"=>{"2"=>"", "3"=>"NFK"},"North Korea"=>{"2"=>"KP", "3"=>"PRK"},"Northern Mariana Islands"=>{"2"=>"MP", "3"=>"MNP"},"Norway"=>{"2"=>"NO", "3"=>"NOR"},"Oman"=>{"2"=>"OM", "3"=>"OMN"},"Pakistan"=>{"2"=>"PK", "3"=>"PAK"},"Palau"=>{"2"=>"PW", "3"=>"PLW"},"Panama"=>{"2"=>"PA", "3"=>"PAN"},"Papua New Guinea"=>{"2"=>"PG", "3"=>"PNG"},"Paraguay"=>{"2"=>"PY", "3"=>"PRY"},"Peru"=>{"2"=>"PE", "3"=>"PER"},"Philippines"=>{"2"=>"PH", "3"=>"PHL"},"Pitcairn Islands"=>{"2"=>"PN", "3"=>"PCN"},"Poland"=>{"2"=>"PL", "3"=>"POL"},"Portugal"=>{"2"=>"PT", "3"=>"PRT"},"Puerto Rico"=>{"2"=>"PR", "3"=>"PRI"},"Qatar"=>{"2"=>"QA", "3"=>"QAT"},"Republic of the Congo"=>{"2"=>"CG", "3"=>"COG"},"Romania"=>{"2"=>"RO", "3"=>"ROU"},"Russia"=>{"2"=>"RU", "3"=>"RUS"},"Rwanda"=>{"2"=>"RW", "3"=>"RWA"},"Saint Barthelemy"=>{"2"=>"BL", "3"=>"BLM"},"Saint Helena"=>{"2"=>"SH", "3"=>"SHN"},"Saint Kitts and Nevis"=>{"2"=>"KN", "3"=>"KNA"},"Saint Lucia"=>{"2"=>"LC", "3"=>"LCA"},"Saint Martin"=>{"2"=>"MF", "3"=>"MAF"},"Saint Pierre and Miquelon"=>{"2"=>"PM", "3"=>"SPM"},"Saint Vincent and the Grenadines"=>{"2"=>"VC", "3"=>"VCT"},"Samoa"=>{"2"=>"WS", "3"=>"WSM"},"San Marino"=>{"2"=>"SM", "3"=>"SMR"},"Sao Tome and Principe"=>{"2"=>"ST", "3"=>"STP"},"Saudi Arabia"=>{"2"=>"SA", "3"=>"STP"},"Saudi Arabia"=>{"2"=>"SA", "3"=>"SAU"},"Senegal"=>{"2"=>"SN", "3"=>"SEN"},"Serbia"=>{"2"=>"RS", "3"=>"SRB"},"Seychelles"=>{"2"=>"SC", "3"=>"SYC"},"Sierra Leone"=>{"2"=>"SL", "3"=>"SLE"},"Singapore"=>{"2"=>"SG", "3"=>"SGP"},"Slovakia"=>{"2"=>"SK", "3"=>"SVK"},"Slovenia"=>{"2"=>"SI", "3"=>"SVN"},"Solomon Islands"=>{"2"=>"SB", "3"=>"SLB"},"Somalia"=>{"2"=>"SO", "3"=>"SOM"},"South Africa"=>{"2"=>"ZA", "3"=>"ZAF"},"South Korea"=>{"2"=>"KR", "3"=>"KOR"},"Spain"=>{"2"=>"ES", "3"=>"ESP"},"Sri Lanka"=>{"2"=>"LK", "3"=>"LKA"},"Sudan"=>{"2"=>"SD", "3"=>"SDN"},"Suriname"=>{"2"=>"SR", "3"=>"SUR"},"Svalbard"=>{"2"=>"SJ", "3"=>"SJM"},"Swaziland"=>{"2"=>"SZ", "3"=>"SWZ"},"Sweden"=>{"2"=>"SE", "3"=>"SWE"},"Switzerland"=>{"2"=>"CH", "3"=>"CHE"},"Syria"=>{"2"=>"SY", "3"=>"SYR"},"Taiwan"=>{"2"=>"TW", "3"=>"TWN"},"Tajikistan"=>{"2"=>"TJ", "3"=>"TJK"},"Tanzania"=>{"2"=>"TZ", "3"=>"TZA"},"Thailand"=>{"2"=>"TH", "3"=>"THA"},"Timor-Leste"=>{"2"=>"TL", "3"=>"TLS"},"Togo"=>{"2"=>"TG", "3"=>"TGO"},"Tokelau"=>{"2"=>"TK", "3"=>"TKL"},"Tonga"=>{"2"=>"TO", "3"=>"TON"},"Trinidad and Tobago"=>{"2"=>"TT", "3"=>"TTO"},"Tunisia"=>{"2"=>"TN", "3"=>"TUN"},"Turkey"=>{"2"=>"TR", "3"=>"TUR"},"Turkmenistan"=>{"2"=>"TM", "3"=>"TKM"},"Turks and Caicos Islands"=>{"2"=>"TC", "3"=>"TCA"},"Tuvalu"=>{"2"=>"TV", "3"=>"TUV"},"Uganda"=>{"2"=>"UG", "3"=>"UGA"},"Ukraine"=>{"2"=>"UA", "3"=>"UKR"},"United Arab Emirates"=>{"2"=>"AE", "3"=>"ARE"},"United Kingdom"=>{"2"=>"GB", "3"=>"GBR"},"United States"=>{"2"=>"US", "3"=>"USA"},"Uruguay"=>{"2"=>"UY", "3"=>"URY"},"US Virgin Islands"=>{"2"=>"VI", "3"=>"VIR"},"Uzbekistan"=>{"2"=>"UZ", "3"=>"UZB"},"Vanuatu"=>{"2"=>"VU", "3"=>"VUT"},"Venezuela"=>{"2"=>"VE", "3"=>"VEN"},"Vietnam"=>{"2"=>"VN", "3"=>"VNM"},"Wallis and Futuna"=>{"2"=>"WF", "3"=>"WLF"},"West Bank"=>{"2"=>"", "3"=>""},"Western Sahara"=>{"2"=>"EH", "3"=>"ESH"},"Yemen"=>{"2"=>"YE", "3"=>"YEM"},"Zambia"=>{"2"=>"ZM", "3"=>"ZMB"},"Zimbabwe"=>{"2"=>"ZW", "3"=>"ZWE"}}
14
+ hash_value
15
+ new_hash = {}
16
+ hash_value.each_pair do |k,v|
17
+ new_hash.merge!({k.downcase => v})
18
+ end
19
+ new_hash
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: country_code
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ashish Prajapati
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Now you can find the country code by country name. There are lots of
14
+ gem available but those not works oppositly for country name to country code
15
+ email: mail@ashishprajapati.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/country_code.rb
21
+ homepage: http://rubygems.org/gems/country_code
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.0
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Easyiest way to find the country code using country name
44
+ test_files: []