Class: EmPipelines::IOEventSource
- Inherits:
-
EventSource
- Object
- EventSource
- EmPipelines::IOEventSource
- Defined in:
- lib/empipelines/io_event_source.rb
Instance Method Summary collapse
-
#initialize(em, file_path) ⇒ IOEventSource
constructor
A new instance of IOEventSource.
- #start! ⇒ Object
Methods inherited from EventSource
Constructor Details
#initialize(em, file_path) ⇒ IOEventSource
Returns a new instance of IOEventSource.
6 7 8 9 |
# File 'lib/empipelines/io_event_source.rb', line 6 def initialize(em, file_path) raise "File #{file_path} does not exist!" unless File.exists?(file_path) @em, @file_path = em, file_path end |
Instance Method Details
#start! ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/empipelines/io_event_source.rb', line 11 def start! #TODO: this sucks hard, move to evented I/O events = IO.readlines(@file_path).map { |e| e.strip } wrapped_handler = BatchEventSource.new(@em, @file_path, events) wrapped_handler.on_event(event_handler) wrapped_handler.on_finished { |*ignored| finished! } wrapped_handler.start! end |