Sha256: 630eaed74dee5e4db9d7166ff3b018ebb8ecdbd6ca19783b7769d5aadb4690b3
Contents?: true
Size: 578 Bytes
Versions: 1
Compression:
Stored size: 578 Bytes
Contents
require 'socket' require 'uri' require_relative 'value' module Kamerling class Addr < Value vals host: String, port: Integer, prot: Symbol def self.[](host, port, prot) new(host: host, port: port, prot: prot) end def connectable? TCPSocket.open(*self).close true rescue Errno::ECONNREFUSED false end def to_a [host, port] end def to_h attributes.merge(prot: prot.to_s) end def to_s uri.to_s end def uri URI.parse("#{prot.downcase}://#{host}:#{port}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kamerling-0.0.3 | lib/kamerling/addr.rb |