Class: Net::WriteAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/net/protocol.rb

Overview

The writer adapter class

Instance Method Summary collapse

Constructor Details

#initialize(socket, method) ⇒ WriteAdapter

Returns a new instance of WriteAdapter



334
335
336
337
# File 'lib/net/protocol.rb', line 334

def initialize(socket, method)
  @socket = socket
  @method_id = method
end

Instance Method Details

#<<(str) ⇒ Object



349
350
351
352
# File 'lib/net/protocol.rb', line 349

def <<(str)
  write str
  self
end

#inspectObject



339
340
341
# File 'lib/net/protocol.rb', line 339

def inspect
  "#<#{self.class} socket=#{@socket.inspect}>"
end

#printf(*args) ⇒ Object



358
359
360
# File 'lib/net/protocol.rb', line 358

def printf(*args)
  write sprintf(*args)
end

#puts(str = '') ⇒ Object



354
355
356
# File 'lib/net/protocol.rb', line 354

def puts(str = '')
  write str.chomp("\n") + "\n"
end

#write(str) ⇒ Object Also known as: print



343
344
345
# File 'lib/net/protocol.rb', line 343

def write(str)
  @socket.__send__(@method_id, str)
end