Getting weather of any city with Ruby
well, this is simple, open the url of the Open weather map api and parse it,
i additionally converted it into YML to be human readable.
require 'open-uri'
require 'json'
require 'psych'
city = 'portsaid,egypt'
request = "http://api.openweathermap.org/data/2.5/weather?q=#{city}"
response = open(request).readlines.join
print Psych.dump( JSON.parse(response) )
Written by Emad Elsaid
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#