Sha256: ad79a4fca4e33b63f1b95f27559f6031230842e5762c28bc974da8eeb7fcfe48

Contents?: true

Size: 456 Bytes

Versions: 1

Compression:

Stored size: 456 Bytes

Contents

require 'open-uri'
require 'json'

class SeattleWeather 
  def self.current_temperature
    data = JSON.parse(open("http://openweathermap.org/data/2.1/forecast/city?q=Seattle").read)

    temperature_data = data['list'].first
    the_temp_kelvin = temperature_data['main'].fetch("temp")
    the_temp_fahrenheit = (((the_temp_kelvin - 273) * 1.8 ) + 32).round

    puts "Seattle's current temperature is #{the_temp_fahrenheit} degrees Fahrenheit"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seattle_weather_gem-0.0.0 lib/seattle_weather_gem.rb