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



346
347
348
349
# File 'lib/net/protocol.rb', line 346

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

Instance Method Details

#<<(str) ⇒ Object



361
362
363
364
# File 'lib/net/protocol.rb', line 361

def <<(str)
  write str
  self
end

#inspectObject



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

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

#printf(*args) ⇒ Object



370
371
372
# File 'lib/net/protocol.rb', line 370

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

#puts(str = '') ⇒ Object



366
367
368
# File 'lib/net/protocol.rb', line 366

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

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



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

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