Over a million developers have joined DZone.

Get Any city weather in ruby in 8 lines of code

·

 

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

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}