myweatherforecast 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/myweatherforecast.rb +53 -25
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 510d3e4e9db669fc03db27f521408a6454a58d3c
|
4
|
+
data.tar.gz: 109fccd2a0847fe569554c257cf125a2d6e83bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a0b6563ab60140a186fb93df4466d71593d2f87cf516ab14ba6553edbda7f4546ea74daa11113114ac25bce7801f42db6b9c9864fbbae9f64c205df6691db6
|
7
|
+
data.tar.gz: 9a36714877311ce043d36fcc0d44e3cc38533153a8b7647a4e7d1c2c5ec8ab71b6fc67e21f3927b462fd63a21ad98c6be3604de89ec826edf1410b38c6d72186
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/myweatherforecast.rb
CHANGED
@@ -16,10 +16,10 @@ class MyWeatherForecast
|
|
16
16
|
|
17
17
|
if si then
|
18
18
|
params = { units: 'si' }
|
19
|
-
@tlabel = '
|
19
|
+
@tlabel = '°C'
|
20
20
|
else
|
21
21
|
params = {}
|
22
|
-
@tlabel = '
|
22
|
+
@tlabel = '°F'
|
23
23
|
end
|
24
24
|
|
25
25
|
@forecast = ForecastIO.forecast(lat, lon, params: params)
|
@@ -27,52 +27,80 @@ class MyWeatherForecast
|
|
27
27
|
|
28
28
|
class Day
|
29
29
|
|
30
|
-
def initialize(
|
30
|
+
def initialize(forecast, tlabel)
|
31
31
|
|
32
|
-
@
|
32
|
+
@forecast = forecast
|
33
|
+
@x = forecast.currently
|
33
34
|
@tlabel = tlabel
|
34
35
|
|
36
|
+
end
|
37
|
+
|
38
|
+
def at(raw_hour)
|
39
|
+
|
40
|
+
hour = Time.parse(raw_hour).hour
|
41
|
+
i = 0
|
42
|
+
i += 1 until Time.at(@forecast['hourly']['data'][i]['time']).hour \
|
43
|
+
== hour.to_i
|
44
|
+
@x = @forecast['hourly']['data'][i]
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
def humidity()
|
49
|
+
@x.humidity
|
50
|
+
end
|
51
|
+
|
52
|
+
def icon()
|
53
|
+
@x.icon
|
35
54
|
end
|
36
55
|
|
37
56
|
def to_s
|
38
|
-
"%
|
57
|
+
"%d%s, %s" % [@x.temperature.round, @tlabel, @x.summary]
|
39
58
|
end
|
40
59
|
|
41
60
|
def summary()
|
42
61
|
@x.summary
|
43
62
|
end
|
44
|
-
|
63
|
+
|
45
64
|
def temperature
|
46
|
-
@x.temperature
|
65
|
+
"%s°" % @x.temperature.round
|
47
66
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
def initialize(x, tlabel)
|
53
|
-
|
54
|
-
@x = x
|
55
|
-
@tlabel = tlabel
|
56
|
-
|
67
|
+
|
68
|
+
def time
|
69
|
+
Time.at @x.time
|
57
70
|
end
|
58
71
|
|
59
|
-
def
|
60
|
-
|
72
|
+
def visibility()
|
73
|
+
@x.visibility
|
61
74
|
end
|
62
|
-
|
63
|
-
def
|
64
|
-
@x.
|
75
|
+
|
76
|
+
def windspeed()
|
77
|
+
@x.windSpeed.round
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
class DaysAhead < Day
|
83
|
+
|
84
|
+
def initialize(forecast, tlabel, index: 0)
|
85
|
+
|
86
|
+
@forecast = forecast
|
87
|
+
@x = forecast['hourly']['data'][index]
|
88
|
+
@tlabel = tlabel
|
89
|
+
|
65
90
|
end
|
66
91
|
|
67
92
|
end
|
68
93
|
|
69
94
|
def today()
|
70
|
-
Day.new(@forecast
|
95
|
+
Day.new(@forecast, @tlabel)
|
71
96
|
end
|
72
97
|
|
73
98
|
def tomorrow()
|
74
|
-
|
99
|
+
|
100
|
+
# select tomorrow at midday
|
101
|
+
i = 0
|
102
|
+
i += 1 until Time.at(@forecast['hourly']['data'][i]['time']).hour == 12
|
103
|
+
DaysAhead.new(@forecast, @tlabel, index: i)
|
75
104
|
end
|
76
105
|
|
77
|
-
end
|
78
|
-
|
106
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myweatherforecast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -83,5 +83,5 @@ rubyforge_project:
|
|
83
83
|
rubygems_version: 2.4.8
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
|
-
summary:
|
86
|
+
summary: This gem is a wrapper of the forecast_io gem.
|
87
87
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|