Sha256: 2ddf1918f38b7e4f3e161ead5c5fd207b3e8857780fa644d39d78bc861911d66
Contents?: true
Size: 1.02 KB
Versions: 12
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2018-2023, by Samuel Williams. # Copyright, 2019, by Olle Jonsson. require_relative "../host_endpoint" require_relative "../socket_endpoint" require_relative "../ssl_endpoint" module Async module IO class Endpoint def self.try_convert(specification) if specification.is_a? self specification elsif specification.is_a? Array self.send(*specification) elsif specification.is_a? String self.parse(specification) elsif specification.is_a? ::BasicSocket self.socket(specification) elsif specification.is_a? Generic self.new(specification) else raise ArgumentError.new("Not sure how to convert #{specification} to endpoint!") end end # Generate a list of endpoints from an array. def self.each(specifications, &block) return to_enum(:each, specifications) unless block_given? specifications.each do |specification| yield try_convert(specification) end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems