This is a Ruby wrapper library around the API provided by REST Countries http://restcountries.eu
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib minor fixing and testing Jun 18, 2015
spec minor fixing and testing Jun 18, 2015
.gitignore
.rspec
.travis.yml
Gemfile First commit Apr 8, 2015
LICENSE Add the actual MIT License file Apr 26, 2015
README.md Update README.md Apr 23, 2015
Rakefile
restcountry.gemspec

README.md

Restcountry

This is a sample gem to wrap REST Countries API http://restcountries.eu

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
#=> Italy

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.

Related projects

License

The restcountry GEM is released under the MIT License.