Вы бы использовали динамическую диспетчеризацию ruby.
port = Net::HTTP.send("#{protocol}_default_port")
endpoint = Net::HTTP.new(host, port)
endpoint.use_ssl = protocol == 'https'
request = Net::HTTP::Get.new("/item/#{item}")
request['Authorization'] = "Bearer #{key}"
response = endpoint.request(request)
ИЛИ более элегантным способом:
path = URI('https://example.com')
Net::HTTP.start(path.host, path.port, use_ssl: path.scheme == 'https') do |http|
request = Net::HTTP::Get.new path
request['Authorization'] = "Bearer #{key}"
response = http.request(request)
end