class SimpleMetarParser::Visibility

Constants

MAX_VISIBILITY

max visibility

NEARLY_MAX_VISIBILITY

If visibility is greater than this it assume it is maximum

Attributes

visibility[R]

Public Instance Methods

decode_split(s) click to toggle source
# File lib/simple_metar_parser/metar/visibility.rb, line 18
def decode_split(s)
  # Visibility in meters

  # Europa
  if s =~ /^(\d{4})$/
    @visibility = $1.to_i
  end

  # US
  if s =~ /^(\d{1,3})\/?(\d{0,2})SM$/
    if $2 == ""
      @visibility = $1.to_i * 1600.0
    else
      @visibility = $1.to_f * 1600.0 / $2.to_f
    end
  end

  # constant max value
  if @visibility.to_i >= NEARLY_MAX_VISIBILITY
    @visibility = MAX_VISIBILITY
  end

  if s =~ /^(CAVOK)$/
    @visibility = MAX_VISIBILITY
  end
end
reset() click to toggle source
# File lib/simple_metar_parser/metar/visibility.rb, line 12
def reset
  @visibility = nil
end