class OpenWeatherApi::Forecast
Attributes
attributes[RW]
city[RW]
cnt[RW]
cod[RW]
id[RW]
list[RW]
main[RW]
message[RW]
params[RW]
rain[RW]
Public Instance Methods
attributes=(hash)
click to toggle source
# File lib/open_weather_api/forecast.rb, line 11 def attributes=(hash) hash.each do |key, value| send("#{key}=", value) end end
average_temperature(date)
click to toggle source
# File lib/open_weather_api/forecast.rb, line 39 def average_temperature(date) temp = 0 split_day(date).each do |item| temp += item['main']['temp'] end (temp / split_day(date).count).round(1) end
convert_date(timestamp)
click to toggle source
# File lib/open_weather_api/forecast.rb, line 47 def convert_date(timestamp) Time.at(timestamp).to_date end
error()
click to toggle source
# File lib/open_weather_api/forecast.rb, line 25 def error message end
error?()
click to toggle source
# File lib/open_weather_api/forecast.rb, line 21 def error? true unless cod.eq "200" end
split_day(date)
click to toggle source
# File lib/open_weather_api/forecast.rb, line 29 def split_day(date) day = [] list.each do |item| if convert_date(item['dt']) == date day << item end end day end