wasserstand 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wasserstand/mapper.rb +9 -5
- data/lib/wasserstand/version.rb +1 -1
- data/lib/wasserstand/waterway.rb +2 -2
- data/lib/wasserstand.rb +1 -0
- data/test/unit/test_wasserstand.rb +14 -1
- metadata +1 -1
data/lib/wasserstand/mapper.rb
CHANGED
@@ -21,13 +21,17 @@ module Wasserstand
|
|
21
21
|
def map(node)
|
22
22
|
Waterway.new(node.xpath('name').text) .tap do |ww|
|
23
23
|
node.xpath('item').each do |item|
|
24
|
-
|
25
|
-
|
24
|
+
pegel_name = item.xpath('pegelname').text
|
25
|
+
ww.levels[pegel_name] = Level.new(item.xpath('pegelnummer').text).tap do |pegel|
|
26
|
+
pegel.name = pegel_name
|
26
27
|
pegel.km = item.xpath('km').text
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
datum = item.xpath('datum').text
|
30
|
+
uhrzeit = item.xpath('uhrzeit').text
|
31
|
+
|
32
|
+
messdatum = Time.parse("#{datum} #{uhrzeit}")
|
33
|
+
wert = item.xpath('messwert').text.sub(',', '.').to_f
|
34
|
+
tendenz = item.xpath('tendenz').text.downcase.to_sym
|
31
35
|
|
32
36
|
pegel.measurements << Measurement.new(messdatum, wert, tendenz)
|
33
37
|
end
|
data/lib/wasserstand/version.rb
CHANGED
data/lib/wasserstand/waterway.rb
CHANGED
data/lib/wasserstand.rb
CHANGED
@@ -13,6 +13,19 @@ class TestWasserstand < MiniTest::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_levels
|
16
|
-
assert_equal(1, Waterway['BODENSEE'].
|
16
|
+
assert_equal(1, Waterway['BODENSEE'].levels.size)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_level_lookup
|
20
|
+
assert(Waterway['BODENSEE'].levels['KONSTANZ'])
|
21
|
+
assert(Waterway['ELBE-HAVEL-KANAL'].levels['GENTHIN'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_single_measurement
|
25
|
+
konstanz_measurements = Waterway['BODENSEE'].levels['KONSTANZ'].measurements
|
26
|
+
|
27
|
+
assert_equal(Time.parse('2012-09-13 20:00:00 +0200'), konstanz_measurements.last.date)
|
28
|
+
assert_equal(380.7, konstanz_measurements.last.value)
|
29
|
+
assert_equal(:gleich, konstanz_measurements.last.trend)
|
17
30
|
end
|
18
31
|
end
|