Class: NOAA::HttpService
- Inherits:
-
Object
- Object
- NOAA::HttpService
- Defined in:
- lib/noaa/http_service.rb
Overview
:nodoc:
Instance Method Summary collapse
- #get_current_conditions(station_id) ⇒ Object
- #get_forecast(num_days, lat, lng) ⇒ Object
- #get_station_list ⇒ Object
-
#initialize(http = Net::HTTP) ⇒ HttpService
constructor
A new instance of HttpService.
Constructor Details
#initialize(http = Net::HTTP) ⇒ HttpService
Returns a new instance of HttpService.
3 4 5 |
# File 'lib/noaa/http_service.rb', line 3 def initialize(http = Net::HTTP) @HTTP = http end |
Instance Method Details
#get_current_conditions(station_id) ⇒ Object
7 8 9 |
# File 'lib/noaa/http_service.rb', line 7 def get_current_conditions(station_id) LibXML::XML::Document.string(@HTTP.get(URI.parse("http://www.weather.gov/xml/current_obs/#{station_id}.xml"))) end |
#get_forecast(num_days, lat, lng) ⇒ Object
11 12 13 |
# File 'lib/noaa/http_service.rb', line 11 def get_forecast(num_days, lat, lng) LibXML::XML::Document.string(@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_list ⇒ Object
15 16 17 |
# File 'lib/noaa/http_service.rb', line 15 def get_station_list LibXML::XML::Document.string(@HTTP.get(URI.parse("http://www.weather.gov/xml/current_obs/index.xml"))) end |