DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Emad has posted 58 posts at DZone. View Full User Profile

Get Any city weather in ruby in 8 lines of code

  • submit to reddit
require 'open-uri'
require 'json'
require 'psych'

city = 'portsaid,egypt'
request = "{city}"
response = open(request).readlines.join
print Psych.dump( JSON.parse(response) )