Class: TacviewClient::Reader
- Inherits:
-
Object
- Object
- TacviewClient::Reader
- Defined in:
- lib/tacview_client/reader.rb,
lib/tacview_client/reader/parser.rb
Overview
Reads events from an input source, parses them using the Parser and calls the appropriate event processor method
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- OBJECT_UPDATE_MARKER =
The format that matches the beginning of an ACMI update line
'^\h\h+,'
- OBJECT_DELETION_MARKER =
The format that matches the beginning of an ACMI delete line
'-'
- TIME_UPDATE_MARKER =
The format that matches the beginning of an ACMI time update line
'#'
- GLOBAL_PROPERTY_MARKER =
The format that matches the beginning of an ACMI Property line
'0,'
Instance Method Summary collapse
-
#initialize(input_source:, processor:) ⇒ Reader
constructor
A new instance of Reader.
- #start_reading ⇒ Object
Constructor Details
#initialize(input_source:, processor:) ⇒ Reader
Returns a new instance of Reader.
27 28 29 30 31 32 33 |
# File 'lib/tacview_client/reader.rb', line 27 def initialize(input_source:, processor:) raise ArgumentError, 'input_source cannot be nil' if input_source.nil? raise ArgumentError, 'processor cannot be nil' if processor.nil? @input_source = input_source @processor = processor end |
Instance Method Details
#start_reading ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tacview_client/reader.rb', line 35 def start_reading while (line = @input_source.gets) route_line(line.chomp) end true rescue SignalException exit ensure @input_source.close end |