forked from dblock/open-weather-ruby-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaily_weather.rb
37 lines (34 loc) · 1.52 KB
/
daily_weather.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true
module OpenWeather
module Models
module OneCall
class DailyWeather < Model
property 'dt', transform_with: ->(v) { Time.at(v).utc } # time of the forecasted data UTC
property 'sunrise', transform_with: ->(v) { Time.at(v).utc } # sunrise time, UTC
property 'sunset', transform_with: ->(v) { Time.at(v).utc } # sunset time, UTC
property 'temp'
property 'feels_like'
property 'pressure' # atmospheric pressure on the sea level, hPa
property 'humidity' # humidity, %
# atmospheric temperature (varying according to pressure and humidity)
# below which water droplets begin to condense and dew can form
temperature_property 'dew_point'
speed_property 'wind_speed' # wind speed
speed_property 'wind_gust' # wind gust
property 'wind_deg' # wind direction, degrees (meteorological)
property 'clouds' # cloudiness, %
property 'uvi' # UV index
property 'rain' # precipitation volume, mm
property 'snow' # snow volume, mm
property 'weather'
property 'summary'
def initialize(args = nil, options = {})
super args, options
self.temp = OpenWeather::Models::OneCall::Temp.new(temp, options) if temp
self.feels_like = OpenWeather::Models::OneCall::FeelsLike.new(feels_like, options) if feels_like
self.weather = weather.map { |i| OpenWeather::Models::Weather.new(i, options) } if weather
end
end
end
end
end