Home

Awesome

OpenWeather

Open Weather Gem, A wrapper around open weather API, makes working with weather fun.

Installation

Add this line to your application's Gemfile:

gem 'open_weather_sdk'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install open_weather_sdk

Usage

Configuration

Create a config file in initializers and add an API key config/initializers/open_weather.rb

OpenWeather.config do |config|
  config.api_key = 'your key'
end

Current Weather Data

Params Overview

  ||- name -> string
  ||- id -> string || integer, read more about city id's on https://openweathermap.org/current#cityid
  ||- coords -> array [lon, lat]
  ||- zipcode -> string || integer
  ||- country -> string: country code eg: GH -> Ghana
  |[optional]|- lang -> string: eg: en -> english, fr -> french
  |[optional]|- units -> string: eg: standard, metric, imperial

Get weather by city name

Get weather by zipcode and country code. more info -> openweathermap.org

Get weather by geographic coordinates[lon, lat]. more info -> openweathermap.org

Get weather by city id. more info -> openweathermap.org

Hourly Forecast 4 days [Requires Pro Api]

    OpenWeather::HourlyForecast.by_city(# name, units, lang)
    OpenWeather::HourlyForecast.by_city_id(# id, units, lang)
    OpenWeather::HourlyForecast.by_coords(# [lon lat], units, lang)
    OpenWeather::HourlyForecast.by_find(# [lon, lat], count, units, lang)
    OpenWeather::HourlyForecast.by_zip(# zipcode, units, lang)

Follow me √

Twitter ≈> codesalley

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/codesalley/openweather.

License

The gem is available as open source under the terms of the MIT License.