lib/async/io/address.rb in async-io-0.4.0 vs lib/async/io/address.rb in async-io-0.5.0
- old
+ new
@@ -17,17 +17,23 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
require_relative 'socket'
+require 'uri'
module Async
module IO
class Address < Struct.new(:specification, :options)
include ::Socket::Constants
include Comparable
class << self
+ def parse(string, **options)
+ uri = URI.parse(string)
+ self.__send__(uri.scheme, uri.host, uri.port, **options)
+ end
+
def tcp(*args, **options)
self.new([:tcp, *args], **options)
end
def udp(*args, **options)