Class: HrrRbSftp::Sender

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

Overview

This class implements payload sender.

Instance Method Summary collapse

Constructor Details

#initialize(io_out) ⇒ Sender

Instantiates a new payload sender for the output IO.

Parameters:

  • io_out (IO)

    An IO for output.



13
14
15
# File 'lib/hrr_rb_sftp/sender.rb', line 13

def initialize io_out
  @io_out = io_out
end

Instance Method Details

#send(payload) ⇒ Object

Sends payload_length then payload. Flushes output IO once payload is sent.



21
22
23
24
25
# File 'lib/hrr_rb_sftp/sender.rb', line 21

def send payload
  @io_out.write(Protocol::Common::DataTypes::Uint32.encode(payload.bytesize))
  @io_out.write(payload)
  @io_out.flush
end