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.



448
449
450
451
# File 'lib/net/protocol.rb', line 448

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

Instance Method Details

#<<(str) ⇒ Object



463
464
465
466
# File 'lib/net/protocol.rb', line 463

def <<(str)
  write str
  self
end

#inspectObject



453
454
455
# File 'lib/net/protocol.rb', line 453

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

#printf(*args) ⇒ Object



472
473
474
# File 'lib/net/protocol.rb', line 472

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

#puts(str = '') ⇒ Object



468
469
470
# File 'lib/net/protocol.rb', line 468

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

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



457
458
459
# File 'lib/net/protocol.rb', line 457

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