Class: NoaaWeatherClient::Responses::Station

Inherits:
Object
  • Object
show all
Includes:
ReactiveXmlResponse
Defined in:
lib/noaa_weather_client/responses/station.rb

Instance Method Summary collapse

Methods included from ReactiveXmlResponse

#method_missing, #respond_to_missing?, #source

Constructor Details

#initialize(station) ⇒ Station

Returns a new instance of Station.



8
9
10
# File 'lib/noaa_weather_client/responses/station.rb', line 8

def initialize(station)
  @source = station
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NoaaWeatherClient::Responses::ReactiveXmlResponse

Instance Method Details

#latitudeObject



12
13
14
# File 'lib/noaa_weather_client/responses/station.rb', line 12

def latitude
  source.css('latitude').text.to_f
end

#longitudeObject



16
17
18
# File 'lib/noaa_weather_client/responses/station.rb', line 16

def longitude
  source.css('longitude').text.to_f
end

#xml_urlObject



20
21
22
23
24
25
# File 'lib/noaa_weather_client/responses/station.rb', line 20

def xml_url
  @xml_url ||= begin
                 path = URI(source.css('xml_url').text).path
                 "http://w1.weather.gov#{path}"
               end
end