Class: Pants::Readers::FileReaderConnection
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Pants::Readers::FileReaderConnection
- Includes:
- LogSwitch::Mixin
- Defined in:
- lib/pants/readers/file_reader.rb
Overview
This is the EventMachine connection that reads the source file and puts the read data into the data channel so writers can write as they need to.
Instance Method Summary collapse
-
#initialize(write_to_channel, starter, stopper) ⇒ FileReaderConnection
constructor
A new instance of FileReaderConnection.
- #post_init ⇒ Object
-
#receive_data(data) ⇒ Object
Reads the data and writes it to the data channel.
-
#unbind ⇒ Object
Called when the file is done being read.
Constructor Details
#initialize(write_to_channel, starter, stopper) ⇒ FileReaderConnection
Returns a new instance of FileReaderConnection.
20 21 22 23 24 |
# File 'lib/pants/readers/file_reader.rb', line 20 def initialize(write_to_channel, starter, stopper) @write_to_channel = write_to_channel @stopper = stopper @starter = starter end |
Instance Method Details
#post_init ⇒ Object
26 27 28 |
# File 'lib/pants/readers/file_reader.rb', line 26 def post_init @starter.call end |
#receive_data(data) ⇒ Object
Reads the data and writes it to the data channel.
33 34 35 36 |
# File 'lib/pants/readers/file_reader.rb', line 33 def receive_data(data) log "<< #{data.size}" @write_to_channel << data end |
#unbind ⇒ Object
Called when the file is done being read.
39 40 41 42 |
# File 'lib/pants/readers/file_reader.rb', line 39 def unbind log "Unbinding, done writing, and notifying the stopper..." @stopper.call end |