123456789_123456789_123456789_123456789_123456789_

Class: Net::WriteAdapter

Relationships & Source Files
Inherits: Object
Defined in: lib/net/protocol.rb

Overview

The writer adapter class

Class Method Summary

Instance Method Summary

Constructor Details

.new(socket, method) ⇒ WriteAdapter

[ GitHub ]

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

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

Instance Method Details

#<<(str)

[ GitHub ]

  
# File 'lib/net/protocol.rb', line 399

def <<(str)
  write str
  self
end

#inspect

[ GitHub ]

  
# File 'lib/net/protocol.rb', line 389

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

#printf(*args)

[ GitHub ]

  
# File 'lib/net/protocol.rb', line 408

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

#puts(str = '')

[ GitHub ]

  
# File 'lib/net/protocol.rb', line 404

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

#write(str) Also known as: #print

[ GitHub ]

  
# File 'lib/net/protocol.rb', line 393

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