Sha256: 9987c11d1f5a040da2bff6ea42af6f114c6d4b664a5f8aa5d222363860ec894a

Contents?: true

Size: 340 Bytes

Versions: 1

Compression:

Stored size: 340 Bytes

Contents

module Kamerling
  Addr = Struct.new :host, :port, :prot do
    def connectable?
      TCPSocket.open(*self).close
      true
    rescue Errno::ECONNREFUSED
      false
    end

    def to_a
      [host, port]
    end

    def to_h
      super.merge prot: prot.to_s
    end

    def to_s
      "#{host}:#{port} (#{prot})"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.2 lib/kamerling/addr.rb