Class: NOTAM::Message
- Inherits:
-
Object
- Object
- NOTAM::Message
- Defined in:
- src/notam_parser.rb
Instance Method Summary collapse
-
#initialize(text) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(text) ⇒ Message
Returns a new instance of Message.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'src/notam_parser.rb', line 6 def initialize(text) fail(NOTAM::ParserError, "unsupported format") unless self.class.supported_format? text @text, @items, @data = text, [], {} itemize(departition(@text)).each do |raw_item| item = NOTAM::Item.new(raw_item, data: @data) begin item.parse.merge rescue => e @data[:parse_errors] ||= {} @data[:parse_errors][item.class.to_s[/::(.*)/,1]] = e. end @items << item end @data[:fields] = @items.map { |i| [i.class.to_s[/::(.*)/,1], i.text.gsub(/^.\)/,'')] }.to_h end |