Class: Noaaer::HttpService

Inherits:
Object
  • Object
show all
Defined in:
lib/noaaer/http_service.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(http = Net::HTTP) ⇒ HttpService

Returns a new instance of HttpService.



5
6
7
# File 'lib/noaaer/http_service.rb', line 5

def initialize(http = Net::HTTP)
  @HTTP = http
end

Instance Method Details

#get_current_conditions(station_id) ⇒ Object



9
10
11
# File 'lib/noaaer/http_service.rb', line 9

def get_current_conditions(station_id)
  @HTTP.get(URI.parse("http://www.weather.gov/xml/current_obs/#{station_id}.xml"))
end

#get_forecast(num_days, lat, lng) ⇒ Object



13
14
15
# File 'lib/noaaer/http_service.rb', line 13

def get_forecast(num_days, lat, lng)
  @HTTP.get(URI.parse("http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?lat=#{lat}&lon=#{lng}&format=24+hourly&numDays=#{num_days}"))
end

#get_station_listObject



17
18
19
# File 'lib/noaaer/http_service.rb', line 17

def get_station_list
  @HTTP.get(URI.parse("http://www.weather.gov/xml/current_obs/index.xml"))
end