class Peer
Provide a well defined, cached representation of a peer (address).
Definitions
def self.for(io)
Create a new peer object for the given IO object, using the remote address if available.
Signature
-
returns
Peer | Nil
The peer object, or nil if the remote address is not available.
Implementation
def self.for(io)
if address = io.remote_address
return new(address)
end
end
def initialize(address)
Initialize the peer with the given address.
Signature
-
parameter
address
Addrinfo
The remote address of the peer.
Implementation
def initialize(address)
@address = address
if address.ip?
@ip_address = @address.ip_address
end
end
attr :address
Signature
-
attribute
Addrinfo
The remote address of the peer.
attr :ip_address
Signature
-
attribute
String
The IP address of the peer, if available.