Class: Net::WriteAdapter

Inherits:
Object show all
Defined in:
lib/extensions/net-http/net/protocol.rb

Overview

The writer adapter class

Instance Method Summary collapse

Constructor Details

#initialize(socket, method) ⇒ WriteAdapter

Returns a new instance of WriteAdapter.



340
341
342
343
# File 'lib/extensions/net-http/net/protocol.rb', line 340

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

Instance Method Details

#<<(str) ⇒ Object



355
356
357
358
# File 'lib/extensions/net-http/net/protocol.rb', line 355

def <<(str)
  write str
  self
end

#inspectObject



345
346
347
# File 'lib/extensions/net-http/net/protocol.rb', line 345

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

#printf(*args) ⇒ Object



364
365
366
# File 'lib/extensions/net-http/net/protocol.rb', line 364

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

#puts(str = '') ⇒ Object



360
361
362
# File 'lib/extensions/net-http/net/protocol.rb', line 360

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

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



349
350
351
# File 'lib/extensions/net-http/net/protocol.rb', line 349

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