How to check if a country belongs to Europe

2.8k views Asked by At

I'd like to check if the country name provided belongs to Europe. Does anyone know of a list of european countries that can be used in a Ruby project?

I'd like to do something like this:

spain = Country.named('Spain')

spain.parent # => 'Europe'

japan = Country.named('Japan')

japan.parent # => 'Asia'

https://github.com/jim/carmen/ lets me list subregions of a country, but not a country's parent.

2

There are 2 answers

1
zrl3dx On BEST ANSWER

Try that gem if you really need whole gem for this. You should be able to do:

Country.find_all_countries_by_region('Europe')

to get countries in Europe.

0
AudioBubble On

Check out the Wikipedia article for a complete list. http://en.wikipedia.org/wiki/List_of_European_countries