Skip to content

Instantly share code, notes, and snippets.

@pstengel
Forked from s5csimmons/weather.rb
Last active March 18, 2016 21:07
Show Gist options
  • Save pstengel/9fc0ed3e0df0e4015026 to your computer and use it in GitHub Desktop.
Save pstengel/9fc0ed3e0df0e4015026 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/ruby
require "open-uri"
require "json"
open("http://api.wunderground.com/api/AP_KEY/conditions/bestfct:1/q/pws:KNYSCHEN27.json") do |f|
now = JSON.parse(f.read)["current_observation"]
forecast = now.values_at(*%w(weather temp_f relative_humidity wind_mph feelslike_f))
forecast.map! { |f| f.respond_to?(:downcase) ? f.downcase : f }
puts "It's currently %s and %1.1f degrees with %s humidity.
Winds are currently %1.1f mph and it feels like %1.1f degrees." % forecast
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment