Exploring forecast_io

require 'forecast_io'

ForecastIO.configure do |configuration|
  configuration.api_key = '465e3ad0267363820tc8076sa01ceff8'
end

forecast = ForecastIO.forecast(55.91928883, -3.11704133, params: { units: 'si' })

h.keys

#=> ["latitude", "longitude", "timezone", "offset", "currently", "minutely", "hourly", "daily", "flags"]

forecast.timezone
#=> "Europe/London"

forecast.offset
#=> 1

forecast.currently
#=> #<Hashie::Mash apparentTemperature=12.56 cloudCover=0.49 dewPoint=9.58 humidity=0.82 icon="wind"nearestStormBearing=293 nearestStormDistance=24 ozone=285.48 precipIntensity=0 precipProbability=0 pressure=1002.45 summary="Breezy and Partly Cloudy" temperature=12.56 time=1445470272 visibility=15.93 windBearing=242 windSpeed=9.18

c = forecast.currently
Time.at c.time
#=> 2015-10-22 00:31:12 +0100

c.temperature
#=> 12.56

forecast['daily']['data'][0]['summary']
#=> "Windy until afternoon and partly cloudy throughout the day."

forecast['daily']['data'][1]['summary']
#=> "Drizzle starting in the evening."

forecast['daily']['data'][2]['summary']
#=> "Light rain until evening."

forecast['daily']['data'][3]['summary']
#=> "Drizzle overnight."

forecast['daily']['data'][0]['time']
#=> 1445468400

Time.at forecast['daily']['data'][0]['time']
#=> 2015-10-22 00:00:00 +0100

Time.at forecast['daily']['data'][1]['time']
#=> 2015-10-23 00:00:00 +0100

Time.at forecast['daily']['data'][2]['time']
#=> 2015-10-24 00:00:00 +0100

Time.at forecast['hourly']['data'][0]['time']
#=> 2015-10-22 10:00:00 +0100

Time.at forecast['hourly']['data'][1]['time']
#=> 2015-10-22 11:00:00 +0100


Resources