Class: IO::Endpoint::AddressEndpoint
- Defined in:
- lib/io/endpoint/address_endpoint.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
Attributes inherited from Generic
Instance Method Summary collapse
-
#bind(wrapper = self.wrapper) {||socket| ...| ... } ⇒ Array(Socket)
Bind a socket to the given address.
-
#connect(wrapper = self.wrapper, &block) ⇒ Socket
Connects a socket to the given address.
-
#initialize(address, **options) ⇒ AddressEndpoint
constructor
A new instance of AddressEndpoint.
- #inspect ⇒ Object
- #to_s ⇒ Object
Methods inherited from Generic
#accept, #bound, #connected, #each, #hostname, #linger, #local_address, parse, #reuse_address?, #reuse_port?, #timeout, #with, #wrapper
Constructor Details
#initialize(address, **options) ⇒ AddressEndpoint
Returns a new instance of AddressEndpoint.
13 14 15 16 17 |
# File 'lib/io/endpoint/address_endpoint.rb', line 13 def initialize(address, **) super(**) @address = address end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
34 35 36 |
# File 'lib/io/endpoint/address_endpoint.rb', line 34 def address @address end |
Instance Method Details
#bind(wrapper = self.wrapper) {||socket| ...| ... } ⇒ Array(Socket)
Bind a socket to the given address. If a block is given, the socket will be automatically closed when the block exits.
40 41 42 |
# File 'lib/io/endpoint/address_endpoint.rb', line 40 def bind(wrapper = self.wrapper, &block) [wrapper.bind(@address, **, &block)] end |
#connect(wrapper = self.wrapper, &block) ⇒ Socket
Connects a socket to the given address. If a block is given, the socket will be automatically closed when the block exits.
46 47 48 |
# File 'lib/io/endpoint/address_endpoint.rb', line 46 def connect(wrapper = self.wrapper, &block) wrapper.connect(@address, **, &block) end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/io/endpoint/address_endpoint.rb', line 30 def inspect "\#<#{self.class} address=#{@address.inspect}>" end |
#to_s ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/io/endpoint/address_endpoint.rb', line 19 def to_s case @address.afamily when Socket::AF_INET "inet:#{@address.inspect_sockaddr}" when Socket::AF_INET6 "inet6:#{@address.inspect_sockaddr}" else "address:#{@address.inspect_sockaddr}" end end |