Last Updated: February 25, 2016
·
1.845K
· blazeeboy

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) )