metar-parser 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -1
- data/lib/metar/data.rb +21 -10
- data/lib/metar/parser.rb +2 -0
- data/lib/metar.rb +9 -1
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/metar/data.rb
CHANGED
@@ -76,6 +76,8 @@ module Metar
|
|
76
76
|
hectopascals($1.to_f)
|
77
77
|
when pressure =~ /^A(\d{4})$/
|
78
78
|
inches_of_mercury($1.to_f / 100.0)
|
79
|
+
else
|
80
|
+
nil
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
@@ -226,6 +228,8 @@ module Metar
|
|
226
228
|
visibility1 = Visibility.new(distance1, nil, comparator1)
|
227
229
|
visibility2 = Visibility.new(distance2, nil, comparator2)
|
228
230
|
new(designator, visibility1, visibility2, tendency)
|
231
|
+
else
|
232
|
+
nil
|
229
233
|
end
|
230
234
|
end
|
231
235
|
|
@@ -340,17 +344,22 @@ module Metar
|
|
340
344
|
when sky_condition =~ /^(BKN|FEW|OVC|SCT)(\d+)(CB|TCU|\/{3})?$/
|
341
345
|
quantity = QUANTITY[$1]
|
342
346
|
height = Distance.new($2.to_i * 30.0, { :units => :meters })
|
343
|
-
type =
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
347
|
+
type =
|
348
|
+
case $3
|
349
|
+
when 'CB'
|
350
|
+
'cumulonimbus'
|
351
|
+
when 'TCU'
|
352
|
+
'towering cumulus'
|
353
|
+
when nil
|
354
|
+
nil
|
355
|
+
when '///'
|
356
|
+
nil
|
357
|
+
else
|
358
|
+
raise MetarParserError.new("Unexpected sky condition type: #$3")
|
359
|
+
end
|
353
360
|
new(quantity, height, type)
|
361
|
+
else
|
362
|
+
nil
|
354
363
|
end
|
355
364
|
end
|
356
365
|
|
@@ -378,6 +387,8 @@ module Metar
|
|
378
387
|
Distance.new($1.to_f * 30.0, { :units => :meters })
|
379
388
|
when vertical_visibility == '///'
|
380
389
|
Distance.new
|
390
|
+
else
|
391
|
+
nil
|
381
392
|
end
|
382
393
|
end
|
383
394
|
|
data/lib/metar/parser.rb
CHANGED
data/lib/metar.rb
CHANGED
@@ -8,9 +8,17 @@ module Metar
|
|
8
8
|
module VERSION #:nodoc:
|
9
9
|
MAJOR = 0
|
10
10
|
MINOR = 1
|
11
|
-
TINY =
|
11
|
+
TINY = 3
|
12
12
|
|
13
13
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
14
14
|
end
|
15
15
|
|
16
|
+
# Base class for all Metar exceptions
|
17
|
+
class MetarError < StandardError
|
18
|
+
end
|
19
|
+
|
20
|
+
# Raised when an unrecognized value is found
|
21
|
+
class MetarParserError < MetarError
|
22
|
+
end
|
23
|
+
|
16
24
|
end
|