Problem zi if

Hej mam taki hash (z dwoma kluczami)

hash = { “Server IP not Whitelisted”=> “2”, “Wrong Tracking Protocol” => “1”}

Jak sprawdzic za pomoca if czy te dwa klucze znajduja sie w hashu. Chce miec mozliwosc wykluczenia sprawdzania istnienia pojedynczych kluczy jesli istnieja dwa klucze w danym hashu. W tym przapdku ponizej gdybym sprawdzanie tych dwoch kluczy dal na poczatku byloby wporzadku:

if hash.has_key?(“Wrong Tracking Protocol”) && hash.has_key?(“Server IP not Whitelisted”)

ale w tym przypadku sprawdzany jest pierwszy warunek ktory jest true a pozostale juz nie sa sprawdzane.

if hash.has_key?("Wrong Tracking Protocol") puts "Wrong Tracking Protocol" elsif hash.has_key?("Server IP not Whitelisted") puts "Server IP not Whitelisted" elsif hash.has_key?("Wrong Tracking Protocol") && hash.has_key?("Server IP not Whitelisted") puts "has Wrong Tracking Protocol and Server IP not Whitelisted" end
Moglibyscie podsunac mi jakis pomysl lub alternatywe jak to rozwiazac? Algorytm?

moge tutaj dodac dodatkowe sprawdzanie dlugosci hash’a:

if hash.length == 1 if hash.has_key?("Wrong Tracking Protocol") puts "Wrong Tracking Protocol" comment = "Wrong Tracking Protocol" elsif hash.has_key?("Server IP not Whitelisted") puts "Server IP not Whitelisted" comment = "Server IP not Whitelisted" end else if hash.has_key?("Wrong Tracking Protocol") && hash.has_key?("Server IP not Whitelisted") puts "has Wrong Tracking Protocol and Server IP not Whitelisted" comment = "has Wrong Tracking Protocol and Server IP not Whitelisted" end end

ale co w przypadku gdy tych kluczy jest wiecej? np 3, 4?

jeśli w railsach to może to wystarczy?

hash.keys.to_sentence

Hej sevos, dzieki za podpowiedz, bardzo przydatna metoda

Pozdrawiam
Lukasz