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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc0d18c5a51723006895fd65b0888146e29a2125d4f9b372a768a5af3a28e6f5
4
- data.tar.gz: d2e87e10bfb6be37ef0619fe3ac8db5ebbb4adbf9d6bc424d52cc9b500dd1013
3
+ metadata.gz: e8bd21657beb125dc98f3c51b3977657043ec25c2751808719da0d79d9a60c77
4
+ data.tar.gz: ca55d7395122e2f7fd7d5577bb71bb75cc5f0c3929e00e05a89a4604a7e8821b
5
5
  SHA512:
6
- metadata.gz: 18831efffd3edff23f90912344dd882c1aa4505525e797665431694532d655c589168eea6a16ecd529237175567d76b672ba92492c0e903046beb73c61a5ddec
7
- data.tar.gz: e2ed98299950570703bd68432d15e065e49e98da6cbe4ac60b21ab1dd5618c8d1f45425cac8b99e45bda4b9984f3acaaaa3f99fdbcc9d3e28a7ae1bc3844805a
6
+ metadata.gz: 9774400e23f8776038041b587438d94c6f1290848daa32334bccfe5deb932f4593aa2fb4df749a6cd0f407558fb4a4f1b77ff41bbcb9449f63320d6be212a28e
7
+ data.tar.gz: 977ec6e9f44bf6cb797ef0267ef5b237bb81c35a6a8db281407fe00baea03fa9d92f0d06f2c0c75fdd4f2bf8c3ddd56d62266d2bdf525af7446a79193a2db684
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ quick_test.rb
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- darksky_weather-api (0.2.0)
4
+ darksky_weather-api (0.2.1)
5
5
  activesupport
6
6
  httparty
7
7
 
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
 
@@ -1,5 +1,5 @@
1
1
  module DarkskyWeather
2
2
  module Api
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -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 max_precipitation(hours = hourly)
21
- hours.map{|h| h.precip_intensity }.max || 0
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 max_precipitation_datetime(hours = hourly)
25
- stamp = hours.sort_by{|h| h.precip_intensity.to_f }.last.time
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 = hourly)
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 = hourly)
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 = hourly)
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 = hourly)
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 max_temperature(hours = hourly)
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 = hourly)
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 = hourly)
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 = hourly)
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 = hourly)
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 = hourly)
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 max_wind_gust(hours = hourly)
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 = hourly)
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.0
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-21 00:00:00.000000000 Z
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty