metar-parser 0.1.6 → 0.1.7

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.
Files changed (3) hide show
  1. data/lib/metar/station.rb +7 -4
  2. data/lib/metar.rb +1 -1
  3. metadata +2 -2
data/lib/metar/station.rb CHANGED
@@ -49,13 +49,15 @@ module Metar
49
49
  end
50
50
 
51
51
  def to_longitude(s)
52
- s =~ /^(\d+)-(\d+)([EW])/ or return nil
53
- ($3 == 'E' ? 1.0 : -1.0) * ($1.to_f + $2.to_f / 60.0)
52
+ s =~ /^(\d+)-(\d+)(-(\d+))?([EW])/ or return nil
53
+ seconds = $4 ? $4.to_f / 3600.0 : 0.0
54
+ ($5 == 'E' ? 1.0 : -1.0) * ($1.to_f + $2.to_f / 60.0 + seconds)
54
55
  end
55
56
 
56
57
  def to_latitude(s)
57
- s =~ /^(\d+)-(\d+)([SN])/ or return nil
58
- ($3 == 'N' ? 1.0 : -1.0) * ($1.to_f + $2.to_f / 60.0)
58
+ s =~ /^(\d+)-(\d+)(-(\d+))?([SN])/ or return nil
59
+ seconds = $4 ? $4.to_f / 3600.0 : 0.0
60
+ ($3 == 'N' ? 1.0 : -1.0) * ($1.to_f + $2.to_f / 60.0 + seconds)
59
61
  end
60
62
  end
61
63
 
@@ -159,6 +161,7 @@ module Metar
159
161
 
160
162
  # Get data from the NOAA data file (very slow on first call!)
161
163
  def load!
164
+ return if @loaded
162
165
  noaa_data = Station.find_data_by_cccc(@cccc)
163
166
  raise "Station identifier '#{ @cccc }' not found" if noaa_data.nil?
164
167
  @name = noaa_data[:name]
data/lib/metar.rb CHANGED
@@ -8,7 +8,7 @@ module Metar
8
8
  module VERSION #:nodoc:
9
9
  MAJOR = 0
10
10
  MINOR = 1
11
- TINY = 6
11
+ TINY = 7
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY].join('.')
14
14
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Yates