Created
August 7, 2014 05:40
-
-
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/
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
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