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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48f4290b76ad88f878bc5efb715d904ba0342702
4
- data.tar.gz: dba5e9e6877bc17530ac2f1bed21aa9ca02fbcb3
3
+ metadata.gz: 510d3e4e9db669fc03db27f521408a6454a58d3c
4
+ data.tar.gz: 109fccd2a0847fe569554c257cf125a2d6e83bb0
5
5
  SHA512:
6
- metadata.gz: 1a1e1d7dd426fde6c9cf07244f90dc6341bb6d1df5ae965585db25cdd7daaf34b93a657812e9c642fd2433b9df52f5c4e5d20d1fc90f0ed32beadacc83c29038
7
- data.tar.gz: ad4a89bb270501e7ddfdfb881b46d2cab50be19ab83d6f9b5c4c235f48d4987c9d601e50a563929c199b4ec8d0786997782e87e95968e71cfa2bafea4e79562b
6
+ metadata.gz: e4a0b6563ab60140a186fb93df4466d71593d2f87cf516ab14ba6553edbda7f4546ea74daa11113114ac25bce7801f42db6b9c9864fbbae9f64c205df6691db6
7
+ data.tar.gz: 9a36714877311ce043d36fcc0d44e3cc38533153a8b7647a4e7d1c2c5ec8ab71b6fc67e21f3927b462fd63a21ad98c6be3604de89ec826edf1410b38c6d72186
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -16,10 +16,10 @@ class MyWeatherForecast
16
16
 
17
17
  if si then
18
18
  params = { units: 'si' }
19
- @tlabel = 'degrees Celcius'
19
+ @tlabel = '°C'
20
20
  else
21
21
  params = {}
22
- @tlabel = 'degrees Farenheit'
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(x, tlabel)
30
+ def initialize(forecast, tlabel)
31
31
 
32
- @x = x
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
- "%s %s, %s" % [@x.temperature.round, @tlabel, @x.summary]
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
- end
49
-
50
- class DaysAhead
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 to_s
60
- "%s" % [@x.summary]
72
+ def visibility()
73
+ @x.visibility
61
74
  end
62
-
63
- def summary()
64
- @x.summary
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.currently, @tlabel)
95
+ Day.new(@forecast, @tlabel)
71
96
  end
72
97
 
73
98
  def tomorrow()
74
- DaysAhead.new(@forecast['daily']['data'][1], @tlabel)
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.1.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: myweatherforecast
86
+ summary: This gem is a wrapper of the forecast_io gem.
87
87
  test_files: []
metadata.gz.sig CHANGED
Binary file