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
Bind using the wrapped socket.
-
#connect(&block) ⇒ Object
Connect using the wrapped socket.
-
#initialize(socket, **options) ⇒ SocketEndpoint
constructor
Initialize a new socket endpoint.
-
#inspect ⇒ Object
Get a detailed string representation of the socket endpoint.
- #The wrapped socket.=(wrappedsocket. = (value)) ⇒ Object
-
#to_s ⇒ Object
Get a string representation of the socket endpoint.
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
Initialize a new socket endpoint.
14 15 16 17 18 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 14 def initialize(socket, **) super(**) @socket = socket end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
33 34 35 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 33 def socket @socket end |
Instance Method Details
#bind(&block) ⇒ Object
Bind using the wrapped socket.
39 40 41 42 43 44 45 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 39 def bind(&block) if block_given? yield @socket else return @socket end end |
#connect(&block) ⇒ Object
Connect using the wrapped socket.
51 52 53 54 55 56 57 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 51 def connect(&block) if block_given? yield @socket else return @socket end end |
#inspect ⇒ Object
Get a detailed string representation of the socket endpoint.
28 29 30 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 28 def inspect "\#<#{self.class} #{@socket.inspect}>" end |
#The wrapped socket.=(wrappedsocket. = (value)) ⇒ Object
33 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 33 attr :socket |
#to_s ⇒ Object
Get a string representation of the socket endpoint.
22 23 24 |
# File 'lib/io/endpoint/socket_endpoint.rb', line 22 def to_s "socket:#{@socket}" end |