metar-parser 1.4.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -49
- data/Rakefile +2 -1
- data/lib/metar/data/base.rb +16 -10
- data/lib/metar/data/density_altitude.rb +16 -10
- data/lib/metar/data/direction.rb +10 -4
- data/lib/metar/data/distance.rb +27 -20
- data/lib/metar/data/lightning.rb +69 -60
- data/lib/metar/data/observer.rb +26 -20
- data/lib/metar/data/pressure.rb +28 -22
- data/lib/metar/data/remark.rb +146 -130
- data/lib/metar/data/runway_visible_range.rb +98 -78
- data/lib/metar/data/sky_condition.rb +68 -57
- data/lib/metar/data/speed.rb +21 -14
- data/lib/metar/data/station_code.rb +8 -4
- data/lib/metar/data/temperature.rb +21 -13
- data/lib/metar/data/temperature_and_dew_point.rb +22 -16
- data/lib/metar/data/time.rb +57 -47
- data/lib/metar/data/variable_wind.rb +30 -19
- data/lib/metar/data/vertical_visibility.rb +27 -21
- data/lib/metar/data/visibility.rb +91 -79
- data/lib/metar/data/visibility_remark.rb +16 -5
- data/lib/metar/data/weather_phenomenon.rb +92 -74
- data/lib/metar/data/wind.rb +106 -87
- data/lib/metar/data.rb +25 -23
- data/lib/metar/i18n.rb +5 -2
- data/lib/metar/parser.rb +47 -22
- data/lib/metar/raw.rb +32 -44
- data/lib/metar/report.rb +31 -20
- data/lib/metar/station.rb +28 -19
- data/lib/metar/version.rb +4 -2
- data/lib/metar.rb +2 -1
- data/locales/de.yml +1 -0
- data/locales/en.yml +1 -0
- data/locales/it.yml +1 -0
- data/locales/pt-BR.yml +1 -0
- data/spec/data/density_altitude_spec.rb +2 -1
- data/spec/data/distance_spec.rb +2 -1
- data/spec/data/lightning_spec.rb +26 -9
- data/spec/data/pressure_spec.rb +2 -0
- data/spec/data/remark_spec.rb +26 -9
- data/spec/data/runway_visible_range_spec.rb +71 -35
- data/spec/data/sky_condition_spec.rb +63 -19
- data/spec/data/speed_spec.rb +2 -0
- data/spec/data/temperature_spec.rb +2 -1
- data/spec/data/variable_wind_spec.rb +2 -0
- data/spec/data/vertical_visibility_spec.rb +4 -4
- data/spec/data/visibility_remark_spec.rb +2 -1
- data/spec/data/visibility_spec.rb +46 -25
- data/spec/data/weather_phenomenon_spec.rb +79 -24
- data/spec/data/wind_spec.rb +156 -38
- data/spec/i18n_spec.rb +2 -0
- data/spec/parser_spec.rb +224 -64
- data/spec/raw_spec.rb +40 -68
- data/spec/report_spec.rb +27 -25
- data/spec/spec_helper.rb +5 -6
- data/spec/station_spec.rb +43 -44
- metadata +56 -43
data/spec/data/lightning_spec.rb
CHANGED
@@ -1,13 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Metar::Data::Lightning do
|
4
6
|
context '.parse_chunks' do
|
5
7
|
[
|
6
|
-
[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
[
|
8
|
+
[
|
9
|
+
'direction', 'LTG SE',
|
10
|
+
[:default, nil, ['SE']]
|
11
|
+
],
|
12
|
+
[
|
13
|
+
'distance direction', 'LTG DSNT SE',
|
14
|
+
[:default, 16_093.44, ['SE']]
|
15
|
+
],
|
16
|
+
[
|
17
|
+
'distance direction and direction', 'LTG DSNT NE AND W',
|
18
|
+
[:default, 16_093.44, %w(NE W)]
|
19
|
+
],
|
20
|
+
[
|
21
|
+
'distance direction-direction', 'LTG DSNT SE-SW',
|
22
|
+
[:default, 16_093.44, %w(SE SW)]
|
23
|
+
],
|
24
|
+
[
|
25
|
+
'distance all quandrants', 'LTG DSNT ALQDS',
|
26
|
+
[:default, 16_093.44, %w(N E S W)]
|
27
|
+
]
|
11
28
|
].each do |docstring, section, expected|
|
12
29
|
example docstring do
|
13
30
|
chunks = section.split(' ')
|
@@ -25,9 +42,9 @@ describe Metar::Data::Lightning do
|
|
25
42
|
end
|
26
43
|
|
27
44
|
it 'removes parsed chunks' do
|
28
|
-
chunks =
|
45
|
+
chunks = %w(LTG DSNT SE FOO)
|
29
46
|
|
30
|
-
|
47
|
+
described_class.parse_chunks(chunks)
|
31
48
|
|
32
49
|
expect(chunks).to eq(['FOO'])
|
33
50
|
end
|
@@ -39,9 +56,9 @@ describe Metar::Data::Lightning do
|
|
39
56
|
end
|
40
57
|
|
41
58
|
it "doesn't not fail if all chunks are parsed" do
|
42
|
-
chunks =
|
59
|
+
chunks = %w(LTG DSNT SE)
|
43
60
|
|
44
|
-
|
61
|
+
described_class.parse_chunks(chunks)
|
45
62
|
|
46
63
|
expect(chunks).to eq([])
|
47
64
|
end
|
data/spec/data/pressure_spec.rb
CHANGED
data/spec/data/remark_spec.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Metar::Data::Remark do
|
4
6
|
context '.parse' do
|
5
7
|
it 'delegate to subclasses' do
|
6
|
-
expect(described_class.parse('21012')).
|
8
|
+
expect(described_class.parse('21012')).
|
9
|
+
to be_a(Metar::Data::TemperatureExtreme)
|
7
10
|
end
|
8
11
|
|
9
12
|
it 'returns nil for unrecognised' do
|
@@ -12,13 +15,14 @@ describe Metar::Data::Remark do
|
|
12
15
|
|
13
16
|
context '6-hour maximum or minimum' do
|
14
17
|
[
|
15
|
-
['positive maximum', '10046', [:maximum,
|
18
|
+
['positive maximum', '10046', [:maximum, 4.6]],
|
16
19
|
['negative maximum', '11012', [:maximum, -1.2]],
|
17
|
-
['positive minimum', '20046', [:minimum,
|
18
|
-
['negative minimum', '21012', [:minimum, -1.2]]
|
20
|
+
['positive minimum', '20046', [:minimum, 4.6]],
|
21
|
+
['negative minimum', '21012', [:minimum, -1.2]]
|
19
22
|
].each do |docstring, raw, expected|
|
20
23
|
example docstring do
|
21
|
-
expect(described_class.parse(raw)).
|
24
|
+
expect(described_class.parse(raw)).
|
25
|
+
to be_temperature_extreme(*expected)
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -27,7 +31,7 @@ describe Metar::Data::Remark do
|
|
27
31
|
it 'returns minimum and maximum' do
|
28
32
|
max, min = described_class.parse('400461006')
|
29
33
|
|
30
|
-
expect(max).to be_temperature_extreme(:maximum,
|
34
|
+
expect(max).to be_temperature_extreme(:maximum, 4.6)
|
31
35
|
expect(min).to be_temperature_extreme(:minimum, -0.6)
|
32
36
|
end
|
33
37
|
end
|
@@ -63,10 +67,23 @@ describe Metar::Data::Remark do
|
|
63
67
|
end
|
64
68
|
|
65
69
|
context 'automated station' do
|
66
|
-
|
67
70
|
[
|
68
|
-
[
|
69
|
-
|
71
|
+
[
|
72
|
+
'with precipitation dicriminator',
|
73
|
+
'AO1',
|
74
|
+
[
|
75
|
+
Metar::Data::AutomatedStationType,
|
76
|
+
:with_precipitation_discriminator
|
77
|
+
]
|
78
|
+
],
|
79
|
+
[
|
80
|
+
'without precipitation dicriminator',
|
81
|
+
'AO2',
|
82
|
+
[
|
83
|
+
Metar::Data::AutomatedStationType,
|
84
|
+
:without_precipitation_discriminator
|
85
|
+
]
|
86
|
+
]
|
70
87
|
].each do |docstring, raw, expected|
|
71
88
|
example docstring do
|
72
89
|
aut = described_class.parse(raw)
|
@@ -1,30 +1,29 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "spec_helper"
|
3
4
|
|
4
|
-
RSpec::Matchers.define :be_runway_visible_range do |designator,
|
5
|
+
RSpec::Matchers.define :be_runway_visible_range do |designator, v1, v2, tend|
|
5
6
|
match do |rvr|
|
6
|
-
if rvr.nil?
|
7
|
+
if rvr.nil? && designator.nil?
|
7
8
|
true
|
8
|
-
elsif rvr.nil?
|
9
|
-
false
|
10
|
-
elsif rvr.visibility1.nil? != visibility1.nil?
|
9
|
+
elsif rvr.nil? != designator.nil?
|
11
10
|
false
|
12
|
-
elsif rvr.
|
11
|
+
elsif rvr.visibility1.nil? != v1.nil?
|
13
12
|
false
|
14
|
-
elsif rvr.
|
13
|
+
elsif rvr.visibility2.nil? != v2.nil?
|
15
14
|
false
|
16
|
-
elsif
|
17
|
-
((rvr.visibility1.distance.value - visibility1[0]).abs > 0.01 ||
|
18
|
-
rvr.visibility1.comparator != visibility1[ 2 ])
|
15
|
+
elsif rvr.tendency.nil? != tend.nil?
|
19
16
|
false
|
20
|
-
elsif !
|
21
|
-
((rvr.
|
22
|
-
|
17
|
+
elsif !v1.nil? &&
|
18
|
+
((rvr.visibility1.distance.value - v1[0]).abs > 0.01 ||
|
19
|
+
rvr.visibility1.comparator != v1[2])
|
23
20
|
false
|
24
|
-
elsif
|
21
|
+
elsif !v2.nil? &&
|
22
|
+
((rvr.visibility2.distance.value - v2[0]).abs > 0.02 ||
|
23
|
+
rvr.visibility2.comparator != v2[2])
|
25
24
|
false
|
26
25
|
else
|
27
|
-
|
26
|
+
tend == rvr.tendency
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
@@ -32,17 +31,44 @@ end
|
|
32
31
|
describe Metar::Data::RunwayVisibleRange do
|
33
32
|
context '.parse' do
|
34
33
|
[
|
35
|
-
[
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
[
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
[
|
44
|
-
|
45
|
-
|
34
|
+
[
|
35
|
+
'understands R + nn + / + nnnn', 'R12/3400',
|
36
|
+
['12', [3400.00, nil, nil], nil, nil]
|
37
|
+
],
|
38
|
+
[
|
39
|
+
'understands runway positions: RLC', 'R12L/3400',
|
40
|
+
['12L', [3400.00, nil, nil], nil, nil]
|
41
|
+
],
|
42
|
+
[
|
43
|
+
'understands comparators: PM', 'R12/P3400',
|
44
|
+
['12', [3400.00, nil, :more_than], nil, nil]
|
45
|
+
],
|
46
|
+
[
|
47
|
+
'understands tendencies: NUD', 'R12/3400U',
|
48
|
+
['12', [3400.00, nil, nil], nil, :improving]
|
49
|
+
],
|
50
|
+
[
|
51
|
+
'understands feet', 'R12/3400FT',
|
52
|
+
['12', [1036.32, nil, nil], nil, nil]
|
53
|
+
],
|
54
|
+
[
|
55
|
+
'understands second visibilities (m)', 'R26/0750V1200U',
|
56
|
+
['12', [750.0, nil, nil], [1200.0, nil, nil], :improving]
|
57
|
+
],
|
58
|
+
[
|
59
|
+
'understands second visibilities (ft)', 'R12/1800V3400FT',
|
60
|
+
['12', [548.64, nil, nil], [1036.32, nil, nil], nil]
|
61
|
+
],
|
62
|
+
[
|
63
|
+
'understands second RVR (ft) w/ tendency', 'R29/1800V3400FT/U',
|
64
|
+
['29', [548.64, nil, nil], [1036.32, nil, nil], :improving]
|
65
|
+
],
|
66
|
+
[
|
67
|
+
'returns nil for nil', nil,
|
68
|
+
[nil, nil, nil, nil]
|
69
|
+
]
|
70
|
+
].each do |title, raw, expected|
|
71
|
+
example title do
|
46
72
|
expect(described_class.parse(raw)).to be_runway_visible_range(*expected)
|
47
73
|
end
|
48
74
|
end
|
@@ -59,26 +85,36 @@ describe Metar::Data::RunwayVisibleRange do
|
|
59
85
|
end
|
60
86
|
|
61
87
|
[
|
62
|
-
[
|
63
|
-
|
64
|
-
|
65
|
-
|
88
|
+
[
|
89
|
+
'v1',
|
90
|
+
:en, [[3400.00, nil, nil], nil, nil],
|
91
|
+
'runway 14: 3400m'
|
92
|
+
],
|
93
|
+
[
|
94
|
+
'v1 and v2',
|
95
|
+
:en, [[3400.00, nil, nil], [1900.00, nil, nil], nil],
|
96
|
+
'runway 14: from 3400m to 1900m'
|
97
|
+
],
|
98
|
+
[
|
99
|
+
'v1 and tendency',
|
100
|
+
:en, [[3400.00, nil, nil], nil, :improving],
|
101
|
+
'runway 14: 3400m improving'
|
102
|
+
]
|
103
|
+
].each do |title, locale, (visibility1, visibility2, tendency), expected|
|
66
104
|
d1 = Metar::Data::Distance.new(visibility1[0])
|
67
105
|
v1 = Metar::Data::Visibility.new(
|
68
106
|
nil, distance: d1, direction: visibility1[1], comparator: visibility1[2]
|
69
107
|
)
|
70
108
|
v2 =
|
71
|
-
if !
|
109
|
+
if !visibility2.nil?
|
72
110
|
d2 = Metar::Data::Distance.new(visibility2[0])
|
73
111
|
Metar::Data::Visibility.new(
|
74
112
|
nil,
|
75
113
|
distance: d2, direction: visibility2[1], comparator: visibility2[2]
|
76
114
|
)
|
77
|
-
else
|
78
|
-
nil
|
79
115
|
end
|
80
116
|
|
81
|
-
example
|
117
|
+
example title + " (#{locale})" do
|
82
118
|
I18n.locale = locale
|
83
119
|
subject = described_class.new(
|
84
120
|
nil,
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "spec_helper"
|
3
4
|
|
4
5
|
RSpec::Matchers.define :be_sky_condition do |quantity, height, type|
|
@@ -11,10 +12,8 @@ RSpec::Matchers.define :be_sky_condition do |quantity, height, type|
|
|
11
12
|
false
|
12
13
|
elsif sk.height.is_a?(Metar::Data::Distance) && sk.height.value != height
|
13
14
|
false
|
14
|
-
elsif sk.type != type
|
15
|
-
false
|
16
15
|
else
|
17
|
-
|
16
|
+
sk.type == type
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -22,13 +21,34 @@ end
|
|
22
21
|
describe Metar::Data::SkyCondition do
|
23
22
|
context '.parse' do
|
24
23
|
[
|
25
|
-
[
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
[
|
30
|
-
|
31
|
-
|
24
|
+
[
|
25
|
+
'understands clear skies codes', 'NSC',
|
26
|
+
[nil, nil, nil]
|
27
|
+
],
|
28
|
+
[
|
29
|
+
'quantity + height', 'BKN12',
|
30
|
+
['broken', 365.76, nil]
|
31
|
+
],
|
32
|
+
[
|
33
|
+
'quantity + height + type', 'BKN12CB',
|
34
|
+
['broken', 365.76, 'cumulonimbus']
|
35
|
+
],
|
36
|
+
[
|
37
|
+
'quantity + ///', 'BKN///',
|
38
|
+
['broken', nil, nil]
|
39
|
+
],
|
40
|
+
[
|
41
|
+
'quantity + height + ///', 'FEW038///',
|
42
|
+
['few', 1158.24, nil]
|
43
|
+
],
|
44
|
+
[
|
45
|
+
'cumulonimbus only', 'CB', # seems non-standard, but occurs
|
46
|
+
[nil, nil, 'cumulonimbus']
|
47
|
+
],
|
48
|
+
[
|
49
|
+
'returns nil for unmatched', 'FUBAR',
|
50
|
+
[:expect_nil, nil, nil]
|
51
|
+
]
|
32
52
|
].each do |docstring, raw, expected|
|
33
53
|
example docstring do
|
34
54
|
expect(described_class.parse(raw)).to be_sky_condition(*expected)
|
@@ -38,11 +58,26 @@ describe Metar::Data::SkyCondition do
|
|
38
58
|
|
39
59
|
context '.to_summary' do
|
40
60
|
[
|
41
|
-
[
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
[
|
61
|
+
[
|
62
|
+
'all values nil', [nil, nil, nil],
|
63
|
+
:en, 'clear skies'
|
64
|
+
],
|
65
|
+
[
|
66
|
+
'quantity', ['broken', nil, nil],
|
67
|
+
:en, 'broken cloud'
|
68
|
+
],
|
69
|
+
[
|
70
|
+
'quantity', ['broken', nil, nil],
|
71
|
+
:'en-US', 'broken clouds'
|
72
|
+
],
|
73
|
+
[
|
74
|
+
'quantity + type', ['broken', nil, 'cumulonimbus'],
|
75
|
+
:en, 'broken cumulonimbus'
|
76
|
+
],
|
77
|
+
[
|
78
|
+
'quantity + type', ['broken', nil, 'cumulonimbus'],
|
79
|
+
:'en-US', 'broken cumulonimbus clouds'
|
80
|
+
]
|
46
81
|
].each do |docstring, (quantity, height, type), locale, expected|
|
47
82
|
before { @old_locale = I18n.locale }
|
48
83
|
after { I18n.locale = @old_locale }
|
@@ -59,9 +94,18 @@ describe Metar::Data::SkyCondition do
|
|
59
94
|
|
60
95
|
context '.to_s' do
|
61
96
|
[
|
62
|
-
[
|
63
|
-
|
64
|
-
|
97
|
+
[
|
98
|
+
'all values nil', [nil, nil, nil],
|
99
|
+
'clear skies'
|
100
|
+
],
|
101
|
+
[
|
102
|
+
'quantity', ['broken', 360, nil],
|
103
|
+
'broken cloud at 360'
|
104
|
+
],
|
105
|
+
[
|
106
|
+
'quantity + type', ['broken', 360, 'cumulonimbus'],
|
107
|
+
'broken cumulonimbus at 360'
|
108
|
+
]
|
65
109
|
].each do |docstring, (quantity, height, type), expected|
|
66
110
|
example docstring do
|
67
111
|
subject = described_class.new(
|
data/spec/data/speed_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
RSpec::Matchers.define :be_distance do |expected|
|
@@ -8,10 +10,8 @@ RSpec::Matchers.define :be_distance do |expected|
|
|
8
10
|
false
|
9
11
|
elsif distance.value.nil? && expected.nil?
|
10
12
|
true
|
11
|
-
elsif (distance.value - expected).abs > 0.01
|
12
|
-
false
|
13
13
|
else
|
14
|
-
|
14
|
+
(distance.value - expected).abs <= 0.01
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -21,7 +21,7 @@ describe Metar::Data::VerticalVisibility do
|
|
21
21
|
[
|
22
22
|
['VV + nnn', 'VV300', 9144],
|
23
23
|
['///', '///', nil],
|
24
|
-
['returns nil for unmatched', 'FUBAR', :expect_nil]
|
24
|
+
['returns nil for unmatched', 'FUBAR', :expect_nil]
|
25
25
|
].each do |docstring, raw, expected|
|
26
26
|
example docstring do
|
27
27
|
expect(described_class.parse(raw)).to be_distance(expected)
|
@@ -1,11 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "spec_helper"
|
3
4
|
|
4
5
|
RSpec::Matchers.define :be_visibility do |distance, direction, comparator|
|
5
6
|
match do |visibility|
|
6
|
-
if
|
7
|
+
if visibility.nil? && [distance, direction, comparator].all?(&:nil?)
|
7
8
|
true
|
8
|
-
elsif visibility.nil? != [
|
9
|
+
elsif visibility.nil? != [distance, direction, comparator].all?(&:nil?)
|
9
10
|
false
|
10
11
|
elsif visibility.distance.nil? != distance.nil?
|
11
12
|
false
|
@@ -13,11 +14,13 @@ RSpec::Matchers.define :be_visibility do |distance, direction, comparator|
|
|
13
14
|
false
|
14
15
|
elsif visibility.comparator.nil? != comparator.nil?
|
15
16
|
false
|
16
|
-
elsif visibility.distance.is_a?(Metar::Data::Distance) &&
|
17
|
+
elsif visibility.distance.is_a?(Metar::Data::Distance) &&
|
18
|
+
(visibility.distance.value - distance).abs > 0.01
|
17
19
|
false
|
18
|
-
elsif visibility.direction.is_a?(M9t::Direction) &&
|
20
|
+
elsif visibility.direction.is_a?(M9t::Direction) &&
|
21
|
+
(visibility.direction.value - direction).abs > 0.01
|
19
22
|
false
|
20
|
-
elsif comparator.is_a?(Symbol)
|
23
|
+
elsif comparator.is_a?(Symbol) && visibility.comparator != comparator
|
21
24
|
false
|
22
25
|
else
|
23
26
|
true
|
@@ -28,17 +31,17 @@ end
|
|
28
31
|
describe Metar::Data::Visibility do
|
29
32
|
context '.parse' do
|
30
33
|
[
|
31
|
-
['understands 9999', '9999', [
|
32
|
-
['understands nnnn + NDV', '0123NDV', [
|
33
|
-
['understands n/nSM', '3/4SM', [
|
34
|
-
['understands 3/16SM', '3/16SM', [
|
35
|
-
['understands n n/nSM', '1 1/4SM', [
|
36
|
-
['understands nSM', '5SM', [
|
37
|
-
['understands M1/4SM', 'M1/4SM', [
|
38
|
-
['understands n + KM', '5KM', [
|
39
|
-
['understands n', '500', [
|
40
|
-
['understands n + compass', '500NW', [
|
41
|
-
['returns nil for unmatched', 'FUBAR', [
|
34
|
+
['understands 9999', '9999', [10_000.00, nil, :more_than]],
|
35
|
+
['understands nnnn + NDV', '0123NDV', [123.00, nil, nil]],
|
36
|
+
['understands n/nSM', '3/4SM', [1207.01, nil, nil]],
|
37
|
+
['understands 3/16SM', '3/16SM', [301.752, nil, nil]],
|
38
|
+
['understands n n/nSM', '1 1/4SM', [2011.68, nil, nil]],
|
39
|
+
['understands nSM', '5SM', [8046.72, nil, nil]],
|
40
|
+
['understands M1/4SM', 'M1/4SM', [402.34, nil, :less_than]],
|
41
|
+
['understands n + KM', '5KM', [5000.00, nil, nil]],
|
42
|
+
['understands n', '500', [500.00, nil, nil]],
|
43
|
+
['understands n + compass', '500NW', [500.00, 315.0, nil]],
|
44
|
+
['returns nil for unmatched', 'FUBAR', [nil, nil, nil]]
|
42
45
|
].each do |docstring, raw, expected|
|
43
46
|
example docstring do
|
44
47
|
expect(described_class.parse(raw)).to be_visibility(*expected)
|
@@ -57,15 +60,33 @@ describe Metar::Data::Visibility do
|
|
57
60
|
end
|
58
61
|
|
59
62
|
[
|
60
|
-
[
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
[
|
65
|
-
|
63
|
+
[
|
64
|
+
'with distance',
|
65
|
+
:en, [:set, nil, nil], '4km'
|
66
|
+
],
|
67
|
+
[
|
68
|
+
'with distance and direction',
|
69
|
+
:en, [:set, :set, nil], '4km ESE'
|
70
|
+
],
|
71
|
+
[
|
72
|
+
'with distance and comparator',
|
73
|
+
:en, [:set, nil, :less_than], 'less than 4km'
|
74
|
+
],
|
75
|
+
[
|
76
|
+
'with distance, direction and comparator',
|
77
|
+
:en, %i(set set more_than), 'more than 4km ESE'
|
78
|
+
],
|
79
|
+
[
|
80
|
+
'with distance and direction',
|
81
|
+
:it, [:set, :set, nil], '4km ESE'
|
82
|
+
],
|
83
|
+
[
|
84
|
+
'with distance, direction and comparator',
|
85
|
+
:it, %i(set set more_than), 'piú di 4km ESE'
|
86
|
+
]
|
66
87
|
].each do |docstring, locale, (distance, direction, comparator), expected|
|
67
|
-
distance = Metar::Data::Distance.new(4321) if distance
|
68
|
-
direction = M9t::Direction.new(123)
|
88
|
+
distance = Metar::Data::Distance.new(4321) if distance == :set
|
89
|
+
direction = M9t::Direction.new(123) if direction == :set
|
69
90
|
|
70
91
|
example docstring + " (#{locale})" do
|
71
92
|
I18n.locale = locale
|