Giter Site home page Giter Site logo

ruby_open_weather_map's Introduction

A ruby wrapper for Open Weather Map API.

Build Status

Installation

Latest version 0.12.0

Add the following to your Gemfile

gem 'open-weather'

or

$ gem install open-weather

Usage

Current weather information API

require 'open_weather'

# get current weather by city name
OpenWeather::Current.city("Cochin, IN")

# get current weather by city id
OpenWeather::Current.city_id("1273874")

# get current weather by geocode. (lat, lon)
OpenWeather::Current.geocode(9.94, 76.26)

# get current weather for a list of city ids
OpenWeather::Current.cities([524901, 703448, 2643743])

# get current weather for a bounding box
OpenWeather::Current.rectangle_zone(12, 32, 15, 37, 10)

# get current weather for cities around a point
OpenWeather::Current.circle_zone(55.5, 37.5, 10)

# get the current weather in degrees celsius
OpenWeather::Current.city("Cochin, IN", units: 'metric')

Documentation about the current weather end-point: http://openweathermap.org/current

Weather forecast API

require 'open_weather'

# get weather forecast by city name
OpenWeather::Forecast.city("Cochin, IN")

# get weather forecast by city name in fahrenheit
OpenWeather::Forecast.city("Cochin, IN", units: 'imperial')

# get weather forecast by city id
OpenWeather::Forecast.city_id("1273874")

# get weather forecast by geocode. (lat, lon)
OpenWeather::Forecast.geocode(9.94, 76.26)

# get daily weather forecast by city name
OpenWeather::ForecastDaily.city("Cochin, IN")

# get daily weather forecast by city name in fahrenheit
OpenWeather::ForecastDaily.city("Cochin, IN", units: 'imperial')

# get daily weather forecast by city id
OpenWeather::ForecastDaily.city_id("1273874")

# get daily weather forecast by geocode. (lat, lon)
OpenWeather::ForecastDaily.geocode(9.94, 76.26)

# get daily weather forecast for 6 days
OpenWeather::ForecastDaily.city_id("1273874", cnt: 6)

Doucumentation about the weather forecast end-point: http://openweathermap.org/forecast

Using the API key

# get current weather by city name
options = { units: "metric", APPID: 1111111111 }
OpenWeather::Current.city("Berlin, DE", options)

How to get an API key and tips for an effective usage of the API: http://openweathermap.org/appid

Multilingual support

# get current weather in german
OpenWeather::Current.city("Berlin, DE", lang: "de")

Available languages are listed at: http://openweathermap.org/current#multi

Contributing

Fork it

Create your feature branch (git checkout -b my-new-feature)

Commit your changes (git commit -am 'Added some feature')

Push to the branch (git push origin my-new-feature)

Create new Pull Request


This gem was created during the Hacker Saturdays hosted by Kerala/Kochi Ruby Users Group

ruby_open_weather_map's People

Contributors

coderhs avatar deepakkumarnd avatar dnitza avatar yonelacort avatar iamdeuterium avatar ssendev avatar nithinbekal avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.