darksky_weather-api 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/darksky_weather/api/version.rb +1 -1
- data/lib/darksky_weather/api/weather_analysis.rb +48 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8bd21657beb125dc98f3c51b3977657043ec25c2751808719da0d79d9a60c77
|
4
|
+
data.tar.gz: ca55d7395122e2f7fd7d5577bb71bb75cc5f0c3929e00e05a89a4604a7e8821b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9774400e23f8776038041b587438d94c6f1290848daa32334bccfe5deb932f4593aa2fb4df749a6cd0f407558fb4a4f1b77ff41bbcb9449f63320d6be212a28e
|
7
|
+
data.tar.gz: 977ec6e9f44bf6cb797ef0267ef5b237bb81c35a6a8db281407fe00baea03fa9d92f0d06f2c0c75fdd4f2bf8c3ddd56d62266d2bdf525af7446a79193a2db684
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -97,14 +97,18 @@ Whether you're dealing with a `WeatherData` object or a `WeatherCollection`, the
|
|
97
97
|
* `max_preciptiation_datetime`: Returns the datetime when the largest amount of rainful per hour occurred within the data/collection.
|
98
98
|
* `max_accumulation`: Returns the largest amount of snowfall accumulation that occurred within the data/collection.
|
99
99
|
* `max_accumulation_datetime`: Returns the datetime when the largest amount of snowfall accumulation was recorded within the data/collection.
|
100
|
+
* `best_visibility`: Returns the best visibility number within the data/collection.
|
101
|
+
* `best_visibility_datetime`: Returns the datetime when the best visibility within the data/collection was observed.
|
100
102
|
* `worst_visibility`: Returns the worst visibility number within the data/collection.
|
101
103
|
* `worst_visibility_datetime`: Returns the datetime when the worst visibility within the data/collection was observed.
|
104
|
+
* `average_visibility`: Returns the average visibility over the time period within the data/collection.
|
102
105
|
* `max_temperature`: Returns the highest observed temperature within the data/collection
|
103
106
|
* `max_temperature_datetime`: Returns the datetime when the highest observed temperature occurred within the data/collection
|
104
107
|
* `min_temperature`: Returns the lowest observed temperature within the data/collection
|
105
108
|
* `min_temperature_datetime`: Returns the datetime when the lowest observed temperature occurred within the data/collection
|
106
109
|
* `max_wind_speed`: Returns the highest observed windspeed within the data/collection.
|
107
110
|
* `max_wind_speed_datetime`: Returns the datetime when the highest windspeed within the data/collection was observed.
|
111
|
+
* `average_wind_speed`: Returns the average wind speed within the data/collection.
|
108
112
|
* `max_wind_gust`: Returns the highest wind gust speed within the data/collection.
|
109
113
|
* `max_wind_gust_datetime`: Returns the datetime when the highest observed wind gust speed occurred within the data/collection.
|
110
114
|
|
@@ -17,65 +17,97 @@ module DarkskyWeather
|
|
17
17
|
hourly.select{|h| h.time == compare_time.to_i }.first
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
hours.map{|h| h.precip_intensity }.
|
20
|
+
def total_precipitation(type: 'rain', hours: hourly)
|
21
|
+
hours.select{|h| h.precip_type == type }.map{|h| h.precip_intensity.to_f }.sum
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def max_precipitation(type: 'rain', hours: hourly)
|
25
|
+
hours.select{|h| h.precip_type == type }.map{|h| h.precip_intensity }.max || 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def max_precipitation_datetime(type: 'rain', hours: hourly)
|
29
|
+
stamp = hours.select{|h| h.precip_type == type }.sort_by{|h| h.precip_intensity.to_f }.last.time
|
26
30
|
return DateTime.strptime(stamp.to_s, "%s")
|
27
31
|
end
|
28
32
|
|
29
|
-
def max_accumulation(hours
|
33
|
+
def max_accumulation(hours: hourly)
|
30
34
|
hours.map{|h| h.precip_accumulation }.max || 0
|
31
35
|
end
|
32
36
|
|
33
|
-
def max_accumulation_datetime(hours
|
37
|
+
def max_accumulation_datetime(hours: hourly)
|
34
38
|
stamp = hours.sort_by{|h| h.precip_accumulation }.last.time
|
35
39
|
return DateTime.strptime(stamp.to_s, "%s")
|
36
40
|
end
|
37
41
|
|
38
|
-
def worst_visibility(hours
|
42
|
+
def worst_visibility(hours: hourly)
|
39
43
|
hours.map{|h| h.visibility }.min || 10
|
40
44
|
end
|
41
45
|
|
42
|
-
def worst_visibility_datetime(hours
|
46
|
+
def worst_visibility_datetime(hours: hourly)
|
43
47
|
stamp = hours.sort_by{|h| h.visibility }.first.time
|
44
48
|
return DateTime.strptime(stamp.to_s, "%s")
|
45
49
|
end
|
46
50
|
|
47
|
-
def
|
51
|
+
def best_visibility(hours: hourly)
|
52
|
+
hours.map{|h| h.visibility }.max || 10
|
53
|
+
end
|
54
|
+
|
55
|
+
def best_visibility_datetime(hours: hourly)
|
56
|
+
stamp = hours.sort_by{|h| h.visibility }.last.time
|
57
|
+
return DateTime.strptime(stamp.to_s, "%s")
|
58
|
+
end
|
59
|
+
|
60
|
+
def average_visibility(hours: hourly)
|
61
|
+
visibility_total = hours.map{|h| h.visibility }.sum
|
62
|
+
return (visibility_total / hours.count.to_f).to_f
|
63
|
+
end
|
64
|
+
|
65
|
+
def max_temperature(hours: hourly)
|
48
66
|
hours.map{|h| h.temperature }.max
|
49
67
|
end
|
50
68
|
|
51
|
-
def max_temperature_datetime(hours
|
69
|
+
def max_temperature_datetime(hours: hourly)
|
52
70
|
stamp = hours.sort_by{|h| h.temperature }.last.time
|
53
71
|
return DateTime.strptime(stamp.to_s, "%s")
|
54
72
|
end
|
55
73
|
|
56
|
-
def min_temperature(hours
|
74
|
+
def min_temperature(hours: hourly)
|
57
75
|
hours.map{|h| h.temperature }.min
|
58
76
|
end
|
59
77
|
|
60
|
-
def min_temperature_datetime(hours
|
78
|
+
def min_temperature_datetime(hours: hourly)
|
61
79
|
stamp = hours.sort_by{|h| h.temperature }.first.time
|
62
80
|
return DateTime.strptime(stamp.to_s, "%s")
|
63
81
|
end
|
64
82
|
|
65
|
-
def max_wind_speed(hours
|
83
|
+
def max_wind_speed(hours: hourly)
|
66
84
|
hours.map{|h| h.wind_speed }.max
|
67
85
|
end
|
68
86
|
|
69
|
-
def max_wind_speed_datetime(hours
|
87
|
+
def max_wind_speed_datetime(hours: hourly)
|
70
88
|
stamp = hours.sort_by{|h| h.wind_speed }.last.time
|
71
89
|
return DateTime.strptime(stamp.to_s, "%s")
|
72
90
|
end
|
73
91
|
|
74
|
-
def
|
92
|
+
def min_wind_speed(hours: hourly)
|
93
|
+
hours.map{|h| h.wind_speed }.min
|
94
|
+
end
|
95
|
+
|
96
|
+
def min_wind_speed_datetime(hours: hourly)
|
97
|
+
stamp = hours.sort_by{|h| h.wind_speed }.first.time
|
98
|
+
return DateTime.strptime(stamp.to_s, "%s")
|
99
|
+
end
|
100
|
+
|
101
|
+
def average_wind_speed(hours: hourly)
|
102
|
+
total_wind_speed = hours.map{|h| h.wind_speed }.sum
|
103
|
+
(total_wind_speed / hours.count.to_f).to_f
|
104
|
+
end
|
105
|
+
|
106
|
+
def max_wind_gust(hours: hourly)
|
75
107
|
hours.map{|h| h.wind_gust }.max
|
76
108
|
end
|
77
109
|
|
78
|
-
def max_wind_gust_datetime(hours
|
110
|
+
def max_wind_gust_datetime(hours: hourly)
|
79
111
|
stamp = hours.sort_by{|h| h.wind_gust }.last.time
|
80
112
|
return DateTime.strptime(stamp.to_s, "%s")
|
81
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darksky_weather-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lojistic Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|