Class: Metar::Raw::Metar
Overview
Use this class when you only have a METAR string. The date of the reading is decided as follows:
-
the day of the month is extracted from the METAR,
-
the most recent day with that day of the month is taken as the date of the reading.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(metar) ⇒ Metar
constructor
A new instance of Metar.
- #time ⇒ Object
Constructor Details
#initialize(metar) ⇒ Metar
Returns a new instance of Metar.
39 40 41 42 |
# File 'lib/metar/raw.rb', line 39 def initialize() @metar = @time = nil end |
Instance Method Details
#time ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/metar/raw.rb', line 44 def time return @time if @time dom = day_of_month date = Date.today loop do if date.day >= dom @time = Date.new(date.year, date.month, dom) break end # skip to the last day of the previous month date = Date.new(date.year, date.month, 1).prev_day end @time end |