Getting the temperatureMax for forecast.io

109 views Asked by At

I'm writing a little script that does something with the weather in Ruby wrapper. However, I'm running into a wall with the temperatureMax value with the forecast.io API. If I've read the API right, it is getting the high value for the day.

require 'forecast_io'

ForecastIO.configure do |configuration|
  configuration.api_key = 'my-api-key'
end

forecast = ForecastIO.forecast(40.0506, -77.5203)
puts forecast.daily.temperatureMax #Returns null

There is more to the code, other methods and such that I know work and aren't related, but that is the code that doesn't work. It returns no errors, but just turns null and thus outputs nothing.

Specifically, I'm reading this from the API on how I think it should work.

temperatureMin, temperatureMinTime, temperatureMax, and temperatureMaxTime (only defined on daily data points): numerical values representing the minimum and maximumum temperatures (and the UNIX times at which they occur) on the given day in degrees Fahrenheit.

Does anyone have experience with forecast.io to output the high temperature for the day? It should work, it works on their main site.

EDIT: I also should add, doing just...

puts forecast.daily

Will return the full JSON Object with the temperatureMax value there.

1

There are 1 answers

0
nwk On BEST ANSWER
require 'forecast_io'

ForecastIO.configure do |configuration|
  configuration.api_key = 'my-api-key'
end

forecast = ForecastIO.forecast(40.0506, -77.5203)
# forecast.daily.data contains the forecast data for today and the next
# seven days.
puts forecast.daily.data[0].temperatureMax # prints "87.72" right now