0.02
No commit activity in last 3 years
No release in over 3 years
Basic API implementation for REST Countries API http://restcountries.eu
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.0
>= 0
>= 0

Runtime

>= 0
 Project Readme

Restcountry

This is a RubyGem wrapper library around the API provided by Restcountries.

Installation

Add this line to your application's Gemfile:

gem 'restcountry'

And then execute:

$ bundle

Or install it yourself as:

$ gem install restcountry

Usage

require 'restcountry'

# Find all countries
countries = Restcountry::Country.all

# Find a country by name
country = Restcountry::Country.find_by_name('italy')

# Access the country's attributes
country.capital
#=> Rome

country.region
#=> Europe

country.callingCodes
#=> "39"

# Find a country by capital
country = Restcountry::Country.find_by_capital('Rome')

country.name
#=> Italy

countries = Restcountry::Country.find_by_lang('it')

countries.first
#=> Holy See

Attributes

name, capital, altSpellings, relevance, region, subregion, translations, population, latlng, demonym, area, gini, timezones, borders, nativeName, callingCodes, topLevelDomain, alpha2Code, alpha3Code, currencies, languages

Credits

Many thanks to Fayder Florez for his implementation of the API.

Contributors

All Contributors

Related projects

gocountries.

License

The restcountry GEM is released under the MIT License.