Class: Metar::Data::Pressure
Instance Attribute Summary collapse
-
#pressure ⇒ Object
readonly
Returns the value of attribute pressure.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw, pressure:) ⇒ Pressure
constructor
A new instance of Pressure.
- #value ⇒ Object
Constructor Details
#initialize(raw, pressure:) ⇒ Pressure
Returns a new instance of Pressure.
26 27 28 29 |
# File 'lib/metar/data/pressure.rb', line 26 def initialize(raw, pressure:) @raw = raw @pressure = pressure end |
Instance Attribute Details
#pressure ⇒ Object (readonly)
Returns the value of attribute pressure.
24 25 26 |
# File 'lib/metar/data/pressure.rb', line 24 def pressure @pressure end |
Class Method Details
.parse(raw) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/metar/data/pressure.rb', line 6 def self.parse(raw) return nil if raw.nil? m1 = raw.match(/^Q(\d{4})$/) if m1 pressure = M9t::Pressure.hectopascals(m1[1].to_f) return new(raw, pressure: pressure) end m2 = raw.match(/^A(\d{4})$/) if m2 pressure = M9t::Pressure.inches_of_mercury(m2[1].to_f / 100.0) return new(raw, pressure: pressure) end nil end |
Instance Method Details
#value ⇒ Object
31 32 33 |
# File 'lib/metar/data/pressure.rb', line 31 def value pressure.value end |