Class: HrrRbSftp::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/hrr_rb_sftp/receiver.rb

Instance Method Summary collapse

Constructor Details

#initialize(io_in) ⇒ Receiver

Returns a new instance of Receiver.



3
4
5
# File 'lib/hrr_rb_sftp/receiver.rb', line 3

def initialize io_in
  @io_in = io_in
end

Instance Method Details

#receiveObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hrr_rb_sftp/receiver.rb', line 7

def receive
  begin
    paylaod_length = Protocol::Common::DataType::Uint32.decode(@io_in)
  rescue NoMethodError
    nil
  else
    payload = @io_in.read(paylaod_length)
    if payload.nil? || payload.length != paylaod_length
      nil
    else
      payload
    end
  end
end