s44_myweatherforecast 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: b200ab26b815ac2751d6b48ccdf753f852458718
4
- data.tar.gz: b028f8eb216d6b2a8ebcac5e589e0937444c00ea
3
+ metadata.gz: 50a3968fba44cdd7ecef7fc5d582726cca7ac4bd
4
+ data.tar.gz: 9e550dd64b4bf547cf5cb67281884889095406fb
5
5
  SHA512:
6
- metadata.gz: 9dd5e1658982d977ddcb123b24bd4ccd62d14b2c32f6a0c9e3b22e0fa879975d140ad5487faab5d150f58c990ba63ca2c962a7fe40373086ee3bf0bcb1109f0f
7
- data.tar.gz: 1e9fb67681cd1bf267904b6d0935372e244898433f07a79edc6cb8245483635565b0cc401e895fed6329bb413bcda191d9bbd5870d824c9c604870ace480ba28
6
+ metadata.gz: 3b0070eebe6b26cacaa142419af231f8106e9827df1e94428ebbf98938c75f7825c113293859f32a863e1cf0c8e4ced69b80943c8a3817b6333dde6fc067d743
7
+ data.tar.gz: 7993f440d3e1f673d1f9fdb917c89b4971463f6406ea4c662cfde74882df769b3a107b7c79505138538f7daee554c1b681269f4ab8ae39b66254ca49c7cd23da
checksums.yaml.gz.sig CHANGED
Binary file
@@ -34,14 +34,49 @@ class S44_MyWeatherForecast
34
34
  # e.g. is it going to rain tomorrow? return an array of periods within the
35
35
  # day of when it will rain or an empty array if there is no rain forecast
36
36
 
37
- def query(day=:tomorrow, desc='rain')
37
+ def query(day=:tomorrow, desc='rain', time: false, times: false)
38
+
39
+ r2 = %i(morning afternoon evening early_hours night).map do |x|
40
+
41
+ r = if times then
42
+ query_period(day.to_sym, x, desc, single_result: false)
43
+ else
44
+ query_period(day.to_sym, x, desc)
45
+ end
38
46
 
39
- %i(morning afternoon evening early_hours night).select do |x|
40
- @w.method(day.to_sym).call.method(x).call.detect do |x|
41
- x.to_s =~ /#{desc}/i
47
+ next unless r
48
+
49
+ if time then
50
+
51
+ [x, [r.time, r.summary]]
52
+
53
+ elsif times
54
+
55
+ next if r.empty?
56
+ [x, r.map {|y| [y.time, y.summary]}]
57
+
58
+ else
59
+ x
42
60
  end
43
61
  end
44
62
 
63
+ r2.compact
64
+
65
+ end
66
+
67
+ def query_period(day=:tomorrow, period=:afternoon, desc='rain', single_result: true)
68
+
69
+ desc = 'drizzle|rain' if desc =~ /rain/i
70
+ obj_period = @w.method(day.to_sym).call.method(period.to_sym).call
71
+
72
+ return if obj_period.nil?
73
+
74
+ if single_result then
75
+ obj_period.detect {|x| x.to_s =~ /#{desc}/i }
76
+ else
77
+ obj_period.select {|x| x.to_s =~ /#{desc}/i }
78
+ end
79
+
45
80
  end
46
81
 
47
82
  alias this_evening evening
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- }S�D��c��]�F �,�+|3IϨ�2~ikH��D��S6��-�\s{��mߔ�Ў���?�V2+��12?C�����mInV,�].��+."�C��6��"T6)ʉr�ٟ�Έ�e2Ř�'|�xIp�Z}З��pGܣ�!�PO�q')
1
+ ��Me�`�|���&�>J /h�i�]̑�2�yE* NJ���3_^o��j���L�=d+p���f�1dnBr��*�mvN��djb�*���7-�7������J��W߱�tW��J��/��~�/(�)��j�:aa����h#����
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s44_myweatherforecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  wNU0aSGt6u5Oh3cJFs6Zfm4W33vT5usVkr6pvh0cTHy+lAA7bmI4yItqT3Pr3TOD
32
32
  YImZerPvCoY8xQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-04-28 00:00:00.000000000 Z
34
+ date: 2017-08-16 00:00:00.000000000 Z
35
35
  dependencies: []
36
36
  description:
37
37
  email: james@jamesrobertson.eu
metadata.gz.sig CHANGED
Binary file