Class: Protocol::HTTP::Peer

Inherits:
Object
  • Object
show all
Defined in:
lib/protocol/http/peer.rb

Overview

Provide a well defined, cached representation of a peer (address).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ Peer

Initialize the peer with the given address.



22
23
24
25
26
27
28
# File 'lib/protocol/http/peer.rb', line 22

def initialize(address)
	@address = address
	
	if address.ip?
		@ip_address = @address.ip_address
	end
end

Instance Attribute Details

#addressObject (readonly) Also known as: remote_address

Returns the value of attribute address.



31
32
33
# File 'lib/protocol/http/peer.rb', line 31

def address
  @address
end

#ip_addressObject (readonly)

Returns the value of attribute ip_address.



34
35
36
# File 'lib/protocol/http/peer.rb', line 34

def ip_address
  @ip_address
end

#The IP address of the peer, if available.(IPaddressofthepeer) ⇒ Object (readonly)



34
# File 'lib/protocol/http/peer.rb', line 34

attr :ip_address

#The remote address of the peer.(remoteaddressofthepeer.) ⇒ Object (readonly)



31
# File 'lib/protocol/http/peer.rb', line 31

attr :address

Class Method Details

.for(io) ⇒ Object

Create a new peer object for the given IO object, using the remote address if available.



13
14
15
16
17
# File 'lib/protocol/http/peer.rb', line 13

def self.for(io)
	if address = io.remote_address
		return new(address)
	end
end