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.



450
451
452
453
# File 'lib/net/protocol.rb', line 450

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

Instance Method Details

#<<(str) ⇒ Object



465
466
467
468
# File 'lib/net/protocol.rb', line 465

def <<(str)
  write str
  self
end

#inspectObject



455
456
457
# File 'lib/net/protocol.rb', line 455

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

#printf(*args) ⇒ Object



474
475
476
# File 'lib/net/protocol.rb', line 474

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

#puts(str = '') ⇒ Object



470
471
472
# File 'lib/net/protocol.rb', line 470

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

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



459
460
461
# File 'lib/net/protocol.rb', line 459

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