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



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

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

Instance Method Details

#<<(str) ⇒ Object



373
374
375
376
# File 'lib/net/protocol.rb', line 373

def <<(str)
  write str
  self
end

#inspectObject



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

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

#printf(*args) ⇒ Object



382
383
384
# File 'lib/net/protocol.rb', line 382

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

#puts(str = '') ⇒ Object



378
379
380
# File 'lib/net/protocol.rb', line 378

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

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



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

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