Class: IO::Endpoint::SocketEndpoint
- Defined in:
- lib/io/endpoint/socket_endpoint.rb
Overview
This class doesn’t exert ownership over the specified socket, wraps a native ::IO.
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Attributes inherited from Generic
Instance Method Summary collapse
- #bind(&block) ⇒ Object
- #connect(&block) ⇒ Object
-
#initialize(socket, **options) ⇒ SocketEndpoint
constructor
A new instance of SocketEndpoint.
- #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(socket, **options) ⇒ SocketEndpoint
Returns a new instance of SocketEndpoint.
11 12 13 14 15 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 11 def initialize(socket, **) super(**) @socket = socket end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
25 26 27 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 25 def socket @socket end |
Instance Method Details
#bind(&block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 27 def bind(&block) if block_given? yield @socket else return @socket end end |
#connect(&block) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 35 def connect(&block) if block_given? yield @socket else return @socket end end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 21 def inspect "\#<#{self.class} #{@socket.inspect}>" end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 17 def to_s "socket:#{@socket}" end |