Method: Weather::Actions#conditions
- Defined in:
- lib/weather/actions.rb
#conditions(location) ⇒ Hash<Symbol, Object>
Gets weather conditions for the location.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/weather/actions.rb', line 95 def conditions(location) response = get('conditions', location) current_observation = response['current_observation'] display_location = current_observation['display_location'] ret = { full_name: display_location['full'], city_name: display_location['city'], state_abbreviation: display_location['state'], state_name: display_location['state_name'], country: display_location['country'], zip_code: display_location['zip'].to_i, updated: current_observation['observation_time'], weather: current_observation['weather'], formatted_temperature: current_observation['temperature_string'], temperature_f: current_observation['temp_f'], temperature_c: current_observation['temp_c'], humidity: current_observation['relative_humidity'], formatted_wind: current_observation['wind_string'], wind_direction: current_observation['wind_dir'], wind_degrees: current_observation['wind_degrees'], wind_speed: current_observation['wind_mph'], wind_gust_speed: current_observation['wind_gust_mph'].to_i, formatted_feelslike: current_observation['feelslike_string'], feelslike_f: current_observation['feelslike_f'].to_i, feelslike_c: current_observation['feelslike_c'].to_i } ret[:humidity] = ret[:humidity].sub('%', '').to_i ret end |