simple_metar_parser 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -10,6 +10,7 @@ require 'metar/visibility'
10
10
  require 'metar/clouds'
11
11
  require 'metar/metar_specials'
12
12
  require 'metar/metar_other'
13
+ require 'metar/runway'
13
14
 
14
15
  module SimpleMetarParser
15
16
  class Metar
@@ -36,7 +37,8 @@ module SimpleMetarParser
36
37
  :visibility => Visibility.new(self),
37
38
  :clouds => Clouds.new(self),
38
39
  :specials => MetarSpecials.new(self),
39
- :other => MetarOther.new(self)
40
+ :other => MetarOther.new(self),
41
+ :runway => Runway.new(self)
40
42
  }
41
43
 
42
44
  # Create dynamically accessors
@@ -0,0 +1,36 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+
3
+ module SimpleMetarParser
4
+ class Runway < Base
5
+
6
+ def reset
7
+ @runways = Array.new
8
+ end
9
+
10
+ attr_reader :runways
11
+
12
+ def decode_split(s)
13
+ # TODO add variable vis. http://stoivane.iki.fi/metar/
14
+
15
+ if s =~ /R(.{2})\/P(\d{4})(.)/
16
+ h = {
17
+ :runway => $1,
18
+ :visual_range => $2.to_i
19
+ }
20
+
21
+ if $3 == "N"
22
+ elsif $3 == "U"
23
+ h[:change] = :up
24
+ elsif $3 == "D"
25
+ h[:change] = :down
26
+ end
27
+
28
+ @runways << h
29
+
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ end
36
+
@@ -93,7 +93,8 @@ module SimpleMetarParser
93
93
 
94
94
  # Calculate wind parameters, some metar string has multiple winds recorded
95
95
  def recalculate_winds
96
- @wind = @winds.collect { |w| w[:wind] }.inject(0) { |b, i| b + i } / @winds.size
96
+ wind_sum = @winds.collect { |w| w[:wind] }.inject(0) { |b, i| b + i }
97
+ @wind = wind_sum.to_f / @winds.size
97
98
  if @winds.size == 1
98
99
  @wind_direction = @winds.first[:wind_direction]
99
100
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_metar_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000Z
12
+ date: 2012-03-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &28881540 !ruby/object:Gem::Requirement
16
+ requirement: &19519420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.3.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *28881540
24
+ version_requirements: *19519420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &28881060 !ruby/object:Gem::Requirement
27
+ requirement: &19976900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *28881060
35
+ version_requirements: *19976900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &28880580 !ruby/object:Gem::Requirement
38
+ requirement: &20696160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *28880580
46
+ version_requirements: *20696160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &18380860 !ruby/object:Gem::Requirement
49
+ requirement: &20936640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *18380860
57
+ version_requirements: *20936640
58
58
  description: Gem for parsing METARs fast and simple.
59
59
  email: bobikx@poczta.fm
60
60
  executables: []
@@ -78,6 +78,7 @@ files:
78
78
  - lib/simple_metar_parser/metar/metar_specials.rb
79
79
  - lib/simple_metar_parser/metar/metar_time.rb
80
80
  - lib/simple_metar_parser/metar/pressure.rb
81
+ - lib/simple_metar_parser/metar/runway.rb
81
82
  - lib/simple_metar_parser/metar/temperature.rb
82
83
  - lib/simple_metar_parser/metar/visibility.rb
83
84
  - lib/simple_metar_parser/metar/wind.rb
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
99
  version: '0'
99
100
  segments:
100
101
  - 0
101
- hash: 2798011357648341845
102
+ hash: -2722903821692108826
102
103
  required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  none: false
104
105
  requirements: