Class: SimpleMetarParser::Pressure

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

Constant Summary collapse

HG_INCH_TO_HPA =
1013.0/2992.1
HG_MM_TO_HPA =
HG_INCH_TO_HPA * 25.4

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#initialize, #post_process

Constructor Details

This class inherits a constructor from SimpleMetarParser::Base

Instance Attribute Details

#pressureObject (readonly)

Returns the value of attribute pressure.



13
14
15
# File 'lib/simple_metar_parser/metar/pressure.rb', line 13

def pressure
  @pressure
end

Instance Method Details

#decode_split(s) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simple_metar_parser/metar/pressure.rb', line 15

def decode_split(s)
  # Europe
  if s =~ /Q(\d{4})/
    @pressure = $1.to_i
  end
  # US
  if s =~ /A(\d{4})/
    #1013 hPa = 29.921 inNg
    @pressure=(($1.to_f) * HG_INCH_TO_HPA).round
  end
end

#hg_inchObject

inches of Hg



47
48
49
# File 'lib/simple_metar_parser/metar/pressure.rb', line 47

def hg_inch
  self.pressure_hg_inch
end

#hg_mmObject

mm of Hg



42
43
44
# File 'lib/simple_metar_parser/metar/pressure.rb', line 42

def hg_mm
  self.pressure_hg_mm
end

#hpaObject

Pressure in hPa



37
38
39
# File 'lib/simple_metar_parser/metar/pressure.rb', line 37

def hpa
  self.pressure
end

#pressure_hg_inchObject



32
33
34
# File 'lib/simple_metar_parser/metar/pressure.rb', line 32

def pressure_hg_inch
  (@pressure / HG_INCH_TO_HPA).round
end

#pressure_hg_mmObject



27
28
29
30
# File 'lib/simple_metar_parser/metar/pressure.rb', line 27

def pressure_hg_mm
  return nil if self.pressure.nil?
  (@pressure / HG_MM_TO_HPA).round
end

#resetObject



9
10
11
# File 'lib/simple_metar_parser/metar/pressure.rb', line 9

def reset
  @pressure = nil
end