Check if a hash's keys include all of a set of keys
%i[a b c d].all? {|s| hash.key? s}
@Mori's way is best, but here's another way:
([:a, :b, :c, :d] - hash.keys).empty?
or
hash.slice(:a, :b, :c, :d).size == 4
Just in the spirit of TIMTOWTDI, here's another way. If you require 'set'
(in the std lib) then you can do this:
Set[:a,:b,:c,:d].subset? hash.keys.to_set