Class: SimpleMetarParser::Clouds

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_metar_parser/metar/clouds.rb

Constant Summary collapse

CLOUD_CLEAR =

Cloud level - clear sky

(0 * 100.0 / 8.0).round
CLOUD_FEW =

Cloud level - few clouds

(1.5 * 100.0 / 8.0).round
CLOUD_SCATTERED =

Cloud level - scattered

(3.5 * 100.0 / 8.0).round
CLOUD_BROKEN =

Cloud level - broken

(6 * 100.0 / 8.0).round
CLOUD_OVERCAST =

Cloud level - overcast

(8 * 100.0 / 8.0).round
CLOUD_NOT_SIGN =

Cloud level - not significant

(0.5 * 100.0 / 8.0).round

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SimpleMetarParser::Base

Instance Attribute Details

#cloudsObject (readonly)

Returns the value of attribute clouds.



24
25
26
# File 'lib/simple_metar_parser/metar/clouds.rb', line 24

def clouds
  @clouds
end

#clouds_maxObject (readonly)

Returns the value of attribute clouds_max.



24
25
26
# File 'lib/simple_metar_parser/metar/clouds.rb', line 24

def clouds_max
  @clouds_max
end

Instance Method Details

#decode_split(s) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/simple_metar_parser/metar/clouds.rb', line 26

def decode_split(s)
  if s =~ /^(SKC|FEW|SCT|BKN|OVC|NSC)(\d{3}?)$/
    cl = case $1
           when "SKC" then
             CLOUD_CLEAR
           when "FEW" then
             CLOUD_FEW
           when "SCT" then
             CLOUD_SCATTERED
           when "BKN" then
             CLOUD_BROKEN
           when "OVC" then
             CLOUD_OVERCAST
           when "NSC" then
             CLOUD_NOT_SIGN
           else
             CLOUD_CLEAR
         end

    cloud = {
      :coverage => cl
    }
    # optionally cloud bottom
    unless '' == $2.to_s
      cloud[:bottom] = $2.to_i * 30
    end

    @clouds << cloud
    @clouds.uniq!
  end

  # obscured by clouds, vertical visibility
  if s =~ /^(VV)(\d{3}?)$/
    @clouds << {
      :coverage => CLOUD_OVERCAST,
      :vertical_visibility => $2.to_i * 30
    }

    @clouds.uniq!
  end

  if s =~ /^(CAVOK)$/
    # everything is awesome :)
  end

end

#post_processObject

Calculate numeric description of clouds



74
75
76
77
78
79
# File 'lib/simple_metar_parser/metar/clouds.rb', line 74

def post_process
  @clouds_max = 0
  @clouds.each do |c|
    @clouds_max = c[:coverage] if @clouds_max < c[:coverage]
  end
end

#resetObject



19
20
21
22
# File 'lib/simple_metar_parser/metar/clouds.rb', line 19

def reset
  @clouds = Array.new
  @clouds_max = nil
end