/Users/peelman/.rbenv/shims/ruby ~/bin/weather.rb --lat 38.9456155 --long -85.8804469 --key da39a3ee5e6b4b0d3255bfef95601890afd80709
Last active
March 31, 2017 12:18
-
-
Save peelman/1aafe12b08596afdb4c4a7d3a63f34e5 to your computer and use it in GitHub Desktop.
A quick Ruby Script to grab the weather from forecast.io and display the current real temp, current apparent temp, and current conditions in GeekTool.
This file contains 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/bin/ruby | |
require 'forecast_io' | |
require 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: weather.rb --key <api_key> --lat <latitude> --long <longitude>" | |
opts.on('--key', '--api_key API_KEY') { |v| options[:key] = v } | |
opts.on('--lat', '--latitude LATITUDE') { |v| options[:lat] = v } | |
opts.on('--long', '--longitude LONGITUDE') { |v| options[:long] = v } | |
end.parse! | |
ForecastIO.configure do |configuration| | |
configuration.api_key = options[:key] | |
end | |
forecast = ForecastIO.forecast(options[:lat], options[:long], params: { exclude: 'minutely,hourly,daily,alerts,flags' }) | |
puts "#{forecast.currently.temperature}° (#{forecast.currently.apparentTemperature}°) #{forecast.currently.summary}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment