Class: Protocol::HTTP::Peer
- Inherits:
-
Object
- Object
- Protocol::HTTP::Peer
- Defined in:
- lib/protocol/http/peer.rb
Overview
Provide a well defined, cached representation of a peer (address).
Instance Attribute Summary collapse
-
#address ⇒ Object
(also: #remote_address)
readonly
Returns the value of attribute address.
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
- #The IP address of the peer, if available.(IPaddressofthepeer) ⇒ Object readonly
- #The remote address of the peer.(remoteaddressofthepeer.) ⇒ Object readonly
Class Method Summary collapse
-
.for(io) ⇒ Object
Create a new peer object for the given IO object, using the remote address if available.
Instance Method Summary collapse
-
#initialize(address) ⇒ Peer
constructor
Initialize the peer with the given address.
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
#address ⇒ Object (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_address ⇒ Object (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 |