Class: WeatherWeasel::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/weather_weasel/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



4
5
6
7
8
9
# File 'lib/weather_weasel/client.rb', line 4

def initialize
  @api_key = ENV["WUNDERGROUND_API_KEY"]
  unless @api_key 
    raise "no api key defined in environment variables"
  end
end

Instance Method Details

#parse_url(url) ⇒ Object



11
12
13
14
# File 'lib/weather_weasel/client.rb', line 11

def parse_url(url)
  response_body = HTTParty.get("http://api.wunderground.com/api/#{@api_key}/#{url}").body
  JSON.parse(response_body)     
end