Module: NoaaWeatherClient::Responses::ReactiveXmlResponse

Included in:
CurrentObservation, LatLonList, Station
Defined in:
lib/noaa_weather_client/responses/reactive_xml_response.rb

Defined Under Namespace

Classes: NullResponse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/noaa_weather_client/responses/reactive_xml_response.rb', line 4

def method_missing(method_name, *arguments, &block)
  if tag = source.css(method_name.to_s)
    if block
      block.call tag.text
    else
      tag.text
    end
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to_missing?(method_name, include_private = false)
  source.css(method_name.to_s) || super
end

#sourceObject



20
21
22
# File 'lib/noaa_weather_client/responses/reactive_xml_response.rb', line 20

def source
  @source || NullResponse.new
end