-
-
Save pstengel/9fc0ed3e0df0e4015026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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