class NoaaWeatherClient::Responses::CurrentObservation
Public Class Methods
new(response)
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 11 def initialize(response) @source = XmlParserFactory.build_parser.parse response validate! @source, :current_observation init end
Public Instance Methods
dewpoint_celsius()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 25 def dewpoint_celsius @dewpoint_c.to_f end
dewpoint_fahrenheit()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 29 def dewpoint_fahrenheit @dewpoint_f.to_f end
latitude()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 33 def latitude @latitude.to_f end
longitude()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 37 def longitude @longitude.to_f end
observation_time()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 45 def observation_time Time.parse(@observation_time_rfc822.to_s) if @observation_time_rfc822 end
observation_time_string()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 41 def observation_time_string @observation_time end
pressure_in()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 49 def pressure_in @pressure_in.to_f end
pressure_mb()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 53 def pressure_mb @pressure_mb.to_f end
relative_humidity()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 57 def relative_humidity @relative_humidity.to_f end
temperature_celsius()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 17 def temperature_celsius @temp_c.to_f end
temperature_fahrenheit()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 21 def temperature_fahrenheit @temp_f.to_f end
to_hash()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 77 def to_hash arr = instance_variables.map { |v| [ v.to_s[1..-1], instance_variable_get(v) ] unless v =~ /source/ }.compact Hash[arr] end
visibility_mi()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 73 def visibility_mi @visibility_mi.to_f end
wind_degrees()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 61 def wind_degrees @wind_degrees.to_f end
wind_kt()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 65 def wind_kt @wind_kt.to_f end
wind_mph()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 69 def wind_mph @wind_mph.to_f end
Private Instance Methods
init()
click to toggle source
# File lib/noaa_weather_client/responses/current_observation.rb, line 86 def init source.root.elements.each do |e| instance_variable_set("@#{e.name}", e.text) end end