Skip to content

Instantly share code, notes, and snippets.

@beneggett
Created August 7, 2014 05:40
Show Gist options
  • Save beneggett/2697811456dfcd5ed538 to your computer and use it in GitHub Desktop.
Save beneggett/2697811456dfcd5ed538 to your computer and use it in GitHub Desktop.
Simple Weather API class from presentation at DRUG: http://www.meetup.com/DRUG-Downtown-Ruby-Users-Group/events/196172202/
require 'httparty'
class Weather
attr_accessor :city
def initialize(city)
@city = CGI.escape(city)
end
def current_weather
HTTParty.get("http://api.openweathermap.org/data/2.5/weather?q=#{city}")
end
def forecast
HTTParty.get("http://api.openweathermap.org/data/2.5/forecast?q=#{city}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment