Class: Metar::Data::Temperature

Inherits:
M9t::Temperature
  • Object
show all
Defined in:
lib/metar/data/temperature.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(raw) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/metar/data/temperature.rb', line 9

def self.parse(raw)
  return nil if !raw

  m = raw.match(/^(M?)(\d+)$/)
  return nil if !m

  sign = m[1]
  value = m[2].to_i
  value *= -1 if sign == 'M'
  new(value)
end

Instance Method Details

#to_s(options = {}) ⇒ Object



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

def to_s(options = {})
  options = {abbreviated: true, precision: 0}.merge(options)
  super(options)
end