def self.uri(s)
case s
when URI::AMQP then s
when URI::Generic
s.scheme ||= 'amqp'
u = DEFAULT_URI_PARSER.parse(s.to_s)
raise URI::BadURIError, "Not an AMQP URI: '#{u}'" unless u.is_a? URI::AMQP
u
else
s = String.try_convert s
raise ::ArgumentError, "bad argument (expected URI object or URI string)" unless s
case s
when %r{^amqps?:} then DEFAULT_URI_PARSER.parse(s)
when %r{^//} then DEFAULT_URI_PARSER.parse("amqp:#{s}")
else DEFAULT_URI_PARSER.parse("amqp://#{s}")
end
end
rescue =>e
raise e.class, "#{self}.#{__method__}(#{s.inspect}): #{e}"
end