Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Get Any city weather in ruby in 8 lines of code

DZone's Guide to

Get Any city weather in ruby in 8 lines of code

·
Free Resource

 

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:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}