Class: Async::IO::SocketEndpoint
- Defined in:
- lib/async/io/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 Endpoint
Instance Method Summary collapse
- #bind(&block) ⇒ Object
- #connect(&block) ⇒ Object
-
#initialize(socket, **options) ⇒ SocketEndpoint
constructor
A new instance of SocketEndpoint.
- #to_s ⇒ Object
Methods inherited from Endpoint
#accept, each, #each, #hostname, parse, ssl, tcp, try_convert, udp, unix
Constructor Details
#initialize(socket, **options) ⇒ SocketEndpoint
Returns a new instance of SocketEndpoint.
234 235 236 237 238 239 |
# File 'lib/async/io/endpoint.rb', line 234 def initialize(socket, **) super(**) # This socket should already be in the required state. @socket = Async::IO.try_convert(socket) end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
245 246 247 |
# File 'lib/async/io/endpoint.rb', line 245 def socket @socket end |
Instance Method Details
#bind(&block) ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/async/io/endpoint.rb', line 247 def bind(&block) if block_given? yield @socket else return @socket end end |
#connect(&block) ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/async/io/endpoint.rb', line 255 def connect(&block) if block_given? yield @socket else return @socket end end |
#to_s ⇒ Object
241 242 243 |
# File 'lib/async/io/endpoint.rb', line 241 def to_s "\#<#{self.class} #{@socket.inspect}>" end |