This is an interface for getting the current weather data interacting with the openweathermap API (http://openweathermap.org/current).
Add this line to your application's Gemfile:
gem 'open-weather-interface'
And then execute:
$ bundle
Or install it yourself as:
$ gem install open-weather-interface
Call current weather data for one location
You can choose these search methods:
By city name, By city ID, By geographic coordinates
Calls by city name. API respond with a list of results that match a searching word, execute:
response = OpenWeather::Interface.by_city_name('Buenos Aires')
Calls by city name with country code
response = OpenWeather::Interface.by_city_name('Santiago Del Estero', {country_code: 'AR'})
response = OpenWeather::Interface.by_city_id(3435910)
response = OpenWeather::Interface.by_lat_lon(-34.62, -58.38)
You can change to metric or imperial units, for that you have to pass a hash with the key units:
response = OpenWeather::Interface.by_city_id(3435910, {units: 'metric'})
or
response = OpenWeather::Interface..by_city_name('Santiago Del Estero', {units: 'imperial'})
You can use the lang key to get the output in another language:
response = OpenWeather::Interface.by_city_id(3435910, {lang: 'es'})
You can see all the available language codes executing:
OpenWeather::Languages::AVAILABLE
Bug reports and pull requests are welcome on GitHub at https://github.com/brianfalah/open-weather-interface.
The gem is available as open source under the terms of the MIT License.