Class: WeatherWeasel::Client
- Inherits:
-
Object
- Object
- WeatherWeasel::Client
- Defined in:
- lib/weather_weasel/client.rb
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #parse_url(url) ⇒ Object
Constructor Details
#initialize ⇒ Client
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 |