获取 forecast.io 的温度最大值

Getting the temperatureMax for forecast.io

我正在编写一个小脚本,在 Ruby 包装器中对天气进行处理。但是,我 运行 撞到了温度最大值为 forecast.io API 的墙上。如果我没看错 API,它就是当天的最高值。

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

代码、其他方法还有更多我知道有效但不相关的方法,但那是无效的代码。它 return 没有错误,但只是变为 null,因此什么也不输出。

具体来说,我正在从 API 中阅读这篇文章,了解我认为它应该如何工作。

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.

有谁有过forecast.io输出当天高温的经验吗? It should work, it works on their main site.

编辑:我还应该补充一点,只是...

puts forecast.daily

将 return 具有 temperatureMax 值的完整 JSON 对象。

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