shipping-forecast 0.0.1 → 0.0.2
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
- data/lib/shipping_forecast.rb +19 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c2d8b852be63a17f17f6e60f9891f9df93ec832
|
4
|
+
data.tar.gz: 9dff1d3c07fcbc440b33580ee7c57d12d50368dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c92e47bddd83ea519016145714bfefae8c6167d98aee1745d34412e3606a85b5bebdbbb380b742e65effe11e319b4609c0d3df3d624b8ec31041bd255116be
|
7
|
+
data.tar.gz: 0b2821f1a89b0e43c162544625f4e4cb8503d19c9020519b6cfbe090ccd29910559229766975e83f149709dbd9de01678c4b2d0b55b7d570a1bc32a8121ea71a
|
data/lib/shipping_forecast.rb
CHANGED
@@ -4,7 +4,16 @@ require 'ostruct'
|
|
4
4
|
class ShippingForecast
|
5
5
|
URL = "http://www.bbc.co.uk/weather/coast_and_sea/shipping_forecast"
|
6
6
|
|
7
|
-
# Public: Returns a hash of OpenStruct objects, each
|
7
|
+
# Public: Returns a hash of OpenStruct objects, each representing a location report.
|
8
|
+
#
|
9
|
+
# Contents of each report:
|
10
|
+
# warning — If there is a warning in effect, returns an OpenStruct object with attributes:
|
11
|
+
# title – The title of the warning, e.g., "Gale Warning"
|
12
|
+
# issued – When the warning was issued
|
13
|
+
# summary – The text summary of the warning
|
14
|
+
# wind – The wind conditions
|
15
|
+
# seas – The current sea conditions
|
16
|
+
# visibility – The current visibility report
|
8
17
|
def self.report
|
9
18
|
@raw_report ||= new.raw_report
|
10
19
|
end
|
@@ -49,20 +58,20 @@ class ShippingForecast
|
|
49
58
|
# Warnings, if any
|
50
59
|
warning = OpenStruct.new
|
51
60
|
warning_detail = area.search(".warning-detail")
|
52
|
-
warning
|
53
|
-
warning
|
54
|
-
warning
|
61
|
+
warning.title = warning_detail.search("strong").text.gsub(':', '')
|
62
|
+
warning.issued = warning_detail.search(".issued").text
|
63
|
+
warning.summary = warning_detail.search(".summary").text
|
55
64
|
|
56
65
|
# Build the hash
|
57
66
|
area_hash = OpenStruct.new
|
58
67
|
breakdown = area.search("ul").children.search("span")
|
59
68
|
|
60
|
-
area_hash
|
61
|
-
area_hash
|
62
|
-
area_hash
|
63
|
-
area_hash
|
64
|
-
area_hash
|
65
|
-
area_hash
|
69
|
+
area_hash.warning = warning
|
70
|
+
area_hash.location = location
|
71
|
+
area_hash.wind = breakdown[0].text
|
72
|
+
area_hash.seas = breakdown[1].text
|
73
|
+
area_hash.weather = breakdown[2].text
|
74
|
+
area_hash.visibility = breakdown[3].text
|
66
75
|
|
67
76
|
locations[location] = area_hash
|
68
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipping-forecast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ted Nyman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|