class HrrRbSftp::Receiver
This class implements payload receiver.
Public Class Methods
new(io_in)
click to toggle source
Instantiates a new payload receiver for the input IO.
@param io_in [IO] An IO for input.
# File lib/hrr_rb_sftp/receiver.rb, line 13 def initialize io_in @io_in = io_in end
Public Instance Methods
receive()
click to toggle source
Receives payload_length payload. When input IO is EOF, returns nil.
@return [String, nil] Received payload. when input IO is EOF, retruns nil.
# File lib/hrr_rb_sftp/receiver.rb, line 22 def receive begin paylaod_length = Protocol::Common::DataTypes::Uint32.decode(@io_in) rescue NoMethodError nil else payload = @io_in.read(paylaod_length) if payload.nil? || payload.bytesize != paylaod_length nil else payload end end end