Method: NOTAM::Schedule.parse

Defined in:
lib/notam/schedule.rb

.parse(string, base_date:) ⇒ Array<NOTAM::Schedule>

Parse the schedule part of a D item.

Parameters:

  • raw schedule string

  • month and year to assume when missing (day is force set to 1)

Returns:

  • array of at least one schedule object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/notam/schedule.rb', line 66

def parse(string, base_date:)
  @rules, @exceptions = cleanup(string).split(/ EXC /).map(&:strip)
  @base_date = base_date.at(day: 1)
  case @rules
  when /^#{DATETIME_RANGE_RE}$/
    parse_datetimes
  when /^(#{DAY_RE}|#{TIME_RANGE_RE})/
    parse_days
  when /^(#{DATE_RE}|#{MONTH_RE})/
    parse_dates
  else
    fail! "unrecognized schedule"
  end
end