weather_report 0.0.3 → 0.0.4
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.
- data/History.txt +6 -1
- data/lib/weather_report.rb +15 -13
- metadata +2 -2
data/History.txt
CHANGED
data/lib/weather_report.rb
CHANGED
@@ -7,7 +7,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
7
7
|
# Class containing weather observations and forecasts for the location specified by id in the constructor.
|
8
8
|
class WeatherReport
|
9
9
|
|
10
|
-
VERSION = '0.0.
|
10
|
+
VERSION = '0.0.4'
|
11
11
|
|
12
12
|
# The id is the number (1..9999) the BBC uses to identify cities for weather reports
|
13
13
|
attr_reader :id
|
@@ -53,12 +53,14 @@ class WeatherReport
|
|
53
53
|
|
54
54
|
# The url for getting current weather observations from BBC Backstage
|
55
55
|
def observation_url()
|
56
|
-
"http://
|
56
|
+
"http://feeds.bbc.co.uk/weather/feeds/rss/obs/world/#{@id}.xml"
|
57
|
+
#"http://newsrss.bbc.co.uk/weather/forecast/#{@id}/ObservationsRSS.xml"
|
57
58
|
end
|
58
59
|
|
59
60
|
# The url for getting weather forecasts from BBC Backstage
|
60
61
|
def forecast_url()
|
61
|
-
"http://
|
62
|
+
"http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/#{@id}.xml"
|
63
|
+
#"http://newsrss.bbc.co.uk/weather/forecast/#{@id}/Next3DaysRSS.xml"
|
62
64
|
end
|
63
65
|
|
64
66
|
end
|
@@ -87,7 +89,7 @@ end
|
|
87
89
|
class WeatherReportObservation
|
88
90
|
include WeatherReportLocation
|
89
91
|
|
90
|
-
DESCRIPTION = /Temperature: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))mph, Relative Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), Pressure: ([\d\.]+|N\/A|NA|\(none\))mB, ([\w -\/]+), Visibility: ([\w -\/]+)/
|
92
|
+
DESCRIPTION = /(.*)Temperature: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))([ ]*)mph, Relative Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), Pressure: ([\d\.]+|N\/A|NA|\(none\))mB, ([\w -\/]+), Visibility: ([\w -\/]+)/
|
91
93
|
SUMMARY = /(.+):(\W+)([\w -\/\(\)]+). (.+)/m
|
92
94
|
|
93
95
|
attr_reader :temperature, :wind_direction, :wind_speed, :visibility, :pressure, :pressure_state, :humidity, :reading_date, :description
|
@@ -107,13 +109,13 @@ class WeatherReportObservation
|
|
107
109
|
doc.elements.each("rss/channel/item[1]/description[1]") { |element|
|
108
110
|
hasDesc = true
|
109
111
|
md = DESCRIPTION.match(element.text)
|
110
|
-
@temperature = md[
|
111
|
-
@wind_direction = md[
|
112
|
-
@wind_speed = md[
|
113
|
-
@humidity = md[
|
114
|
-
@pressure = md[
|
115
|
-
@pressure_state = md[
|
116
|
-
@visibility = md[
|
112
|
+
@temperature = md[2].to_f
|
113
|
+
@wind_direction = md[4]
|
114
|
+
@wind_speed = md[5].to_f * 1.61
|
115
|
+
@humidity = md[7].to_f
|
116
|
+
@pressure = md[9].to_f
|
117
|
+
@pressure_state = md[10]
|
118
|
+
@visibility = md[11]
|
117
119
|
}
|
118
120
|
raise WeatherReport::WeatherReportFormatError unless hasDesc
|
119
121
|
|
@@ -181,7 +183,7 @@ class WeatherReportForecasts < Array
|
|
181
183
|
class WeatherReportForecast
|
182
184
|
|
183
185
|
SUMMARY = /([\w -\/]+): ([\w -]+|N\/A|NA|\(none\)), Max Temp: (.*)/m
|
184
|
-
DESCRIPTION = /Max Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Min Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))mph, Visibility: ([\w -\/]+), Pressure: ([\d\.]+|N\/A|NA|\(none\))
|
186
|
+
DESCRIPTION = /Max Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Min Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))mph, Visibility: ([\w -\/]+), Pressure: ([\d\.]+|N\/A|NA|\(none\))m([bB]), Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), (.+)/m
|
185
187
|
|
186
188
|
attr_reader :max_temperature, :min_temperature, :wind_direction, :wind_speed, :visibility, :pressure, :humidity, :date, :description, :advance_days
|
187
189
|
|
@@ -203,7 +205,7 @@ class WeatherReportForecasts < Array
|
|
203
205
|
@wind_speed = md[6].to_f * 1.61
|
204
206
|
@visibility = md[7]
|
205
207
|
@pressure = md[8].to_f
|
206
|
-
@humidity = md[
|
208
|
+
@humidity = md[10].to_f
|
207
209
|
}
|
208
210
|
end
|
209
211
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weather_report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Cordingley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-19 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|