Sha256: dff57278d2d04c32e467e0792302f9f4706256fc1de31a37e08c202d911a92dc
Contents?: true
Size: 541 Bytes
Versions: 2
Compression:
Stored size: 541 Bytes
Contents
# -*- encoding: utf-8 -*- # -*- frozen_string_literal: true -*- # -*- warn_indent: true -*- class Hash # Returns whether the hash contains all of the specified +keys+. # This method is similar to Hash#key?, but it accepts several keys. # # ==== Arguments # # * +keys+ - +keys+ that needs to be checked in the hash. # # ==== Examples # # {a: 1, b: 2}.keys?(:a, :b) #=> true # {a: 1, b: 2}.keys?(:a, :c) #=> false def keys?(*keys) keys.all? { |key| self.key?(key) } end alias_method :has_keys?, :keys? end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rb_core_extensions-0.1.3 | lib/core_extensions/hash/inclusion.rb |
rb_core_extensions-0.1.2 | lib/core_extensions/hash/inclusion.rb |