Class: SeattleWeather
- Inherits:
-
Object
- Object
- SeattleWeather
- Defined in:
- lib/seattle_weather_gem.rb
Instance Method Summary collapse
Instance Method Details
#current_temp ⇒ Object
15 16 17 18 |
# File 'lib/seattle_weather_gem.rb', line 15 def current_temp kelvin_temp = data_feed['main'].fetch("temp") return "Seattle's current temperature is #{kelvin_to_fahrenheit(kelvin_temp)} degrees Fahrenheit" end |
#data_feed ⇒ Object
6 7 8 9 |
# File 'lib/seattle_weather_gem.rb', line 6 def data_feed data = JSON.parse(open("http://openweathermap.org/data/2.1/forecast/city?q=Seattle").read) current_weather = data['list'].first end |
#kelvin_to_fahrenheit(kelvin_temp) ⇒ Object
11 12 13 |
# File 'lib/seattle_weather_gem.rb', line 11 def kelvin_to_fahrenheit(kelvin_temp) (((kelvin_temp - 273) * 1.8 ) + 32).round end |