Class: NOTAM::Header
Overview
The header item contains the NOTAM ID as well as information as to whether its a new NOTAM or merely replacing or cancelling another one.
Constant Summary collapse
- RE =
%r( \A (?<id>#{ID_RE})\s+ NOTAM(?<operation>[NRC])\s* (?<old_id>#{ID_RE.decapture})? \z )x.freeze
Constants inherited from Item
Item::ICAO_RE, Item::ID_RE, Item::TIME_RE
Instance Attribute Summary
Attributes inherited from Item
Instance Method Summary collapse
-
#cancels ⇒ String?
Message being cancelled by this message or
nil
if this message is a new or replacing one. -
#id ⇒ String
ID of this message.
-
#id_number ⇒ Integer
Serial number.
-
#id_series ⇒ String
Series letter.
-
#id_year ⇒ Integer
Year identifier.
- #inspect ⇒ String
- #merge ⇒ Object
-
#new? ⇒ Boolean
true
if this is a new message,false
if it replaces or cancels another message. - #parse ⇒ Object
-
#replaces ⇒ String?
Message being replaced by this message or
nil
if this message is a new or cancelling one.
Methods inherited from Item
#fail!, #initialize, type, #type
Constructor Details
This class inherits a constructor from NOTAM::Item
Instance Method Details
#cancels ⇒ String?
Returns message being cancelled by this message or nil
if this message is a new or replacing one.
53 54 55 |
# File 'lib/notam/item/header.rb', line 53 def cancels captures['old_id'] if captures['operation'] == 'C' end |
#id ⇒ String
Returns ID of this message.
20 21 22 |
# File 'lib/notam/item/header.rb', line 20 def id captures['id'] end |
#id_number ⇒ Integer
Returns serial number.
30 31 32 |
# File 'lib/notam/item/header.rb', line 30 def id_number captures['id_number'].to_i end |
#id_series ⇒ String
Returns series letter.
25 26 27 |
# File 'lib/notam/item/header.rb', line 25 def id_series captures['id_series'] end |
#id_year ⇒ Integer
Returns year identifier.
35 36 37 |
# File 'lib/notam/item/header.rb', line 35 def id_year captures['id_year'].to_i + (Date.today.year / 1000 * 1000) end |
#inspect ⇒ String
72 73 74 |
# File 'lib/notam/item/header.rb', line 72 def inspect %Q(#<#{self.class} "#{truncated_text(start: 0)}">) end |
#merge ⇒ Object
67 68 69 |
# File 'lib/notam/item/header.rb', line 67 def merge super(:id, :id_series, :id_number, :id_year, :new?, :replaces, :cancels) end |
#new? ⇒ Boolean
Returns true
if this is a new message, false
if it replaces or cancels another message.
41 42 43 |
# File 'lib/notam/item/header.rb', line 41 def new? captures['operation'] == 'N' end |
#parse ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/notam/item/header.rb', line 58 def parse super fail! "invalid operation" unless (new? && !captures['old_id']) || replaces || cancels self rescue fail! 'invalid Header item' end |
#replaces ⇒ String?
Returns message being replaced by this message or nil
if this message is a new or cancelling one.
47 48 49 |
# File 'lib/notam/item/header.rb', line 47 def replaces captures['old_id'] if captures['operation'] == 'R' end |