Class: IO::Endpoint::SocketEndpoint

Inherits:
Generic
  • Object
show all
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

Attributes inherited from Generic

#options

Instance Method Summary collapse

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, **options)
	super(**options)
	
	@socket = socket
end

Instance Attribute Details

#socketObject (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

#inspectObject



21
22
23
# File 'lib/io/endpoint/socket_endpoint.rb', line 21

def inspect
	"\#<#{self.class} #{@socket.inspect}>"
end

#to_sObject



17
18
19
# File 'lib/io/endpoint/socket_endpoint.rb', line 17

def to_s
	"socket:#{@socket}"
end