Sha256: 1bc23c05f0cfab6c9acacd3d9a0e18f52f33650fdd10ca5b04d0c3f4b38d58e3
Contents?: true
Size: 730 Bytes
Versions: 19
Compression:
Stored size: 730 Bytes
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2023, by Samuel Williams. require_relative 'generic' module IO::Endpoint # This class doesn't exert ownership over the specified socket, wraps a native ::IO. class SocketEndpoint < Generic def initialize(socket, **options) super(**options) @socket = socket end def to_s "\#<#{self.class} #{@socket.inspect}>" end attr :socket def bind(&block) if block_given? yield @socket else return @socket end end def connect(&block) if block_given? yield @socket else return @socket end end end def self.socket(socket, **options) SocketEndpoint.new(socket, **options) end end
Version data entries
19 entries across 19 versions & 1 rubygems