Class: Metar::Data::Observer

Inherits:
Base
  • Object
show all
Defined in:
lib/metar/data/observer.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#raw

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, value:) ⇒ Observer

Returns a new instance of Observer.



24
25
26
27
# File 'lib/metar/data/observer.rb', line 24

def initialize(raw, value:)
  @raw = raw
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



22
23
24
# File 'lib/metar/data/observer.rb', line 22

def value
  @value
end

Class Method Details

.parse(raw) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/metar/data/observer.rb', line 6

def self.parse(raw)
  case
  when raw == 'AUTO' # WMO 15.4
    new(raw, value: :auto)
  when raw == 'COR'  # WMO specified code word for correction
    new(raw, value: :corrected)
  when raw =~ /CC[A-Z]/ # Canadian correction
    # Canada uses CCA for first correction, CCB for second, etc...
    new(raw, value: :corrected)
  when raw == 'RTD' #  Delayed observation, no comments on observer
    new(raw, value: :rtd)
  else
    new(nil, value: :real)
  end
end