Sha256: e7f552426741cee09898c158e40fa6719b51a4ee2a5a1eb4b88e3aef82671681

Contents?: true

Size: 603 Bytes

Versions: 11

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

# @api public
# @author darthjee
#
# Extension to core class Object
class Object
  # rubocop:disable Naming/PredicateName

  # @api public
  # Checks if an object is an instance of any of the given classes
  #
  # @param classes [Array<Class>] classes to be checked against object
  #
  # @example
  #   object = [1, 2, 3]
  #
  #   object.is_any?(Hash, Class) # returns false
  #   object.is_any?(Hash, Array) # returns true
  #
  # @return [TrueClass,FalseClass]
  def is_any?(*classes)
    classes.any?(method(:is_a?))
  end
  # rubocop:enable Naming/PredicateName
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sinclair-2.0.1 lib/sinclair/core_ext/object.rb
sinclair-2.0.0 lib/sinclair/core_ext/object.rb
sinclair-1.16.3 lib/sinclair/core_ext/object.rb
sinclair-1.16.2 lib/sinclair/core_ext/object.rb
sinclair-1.16.1 lib/sinclair/core_ext/object.rb
sinclair-1.16.0 lib/sinclair/core_ext/object.rb
sinclair-1.15.0 lib/sinclair/core_ext/object.rb
sinclair-1.14.2 lib/sinclair/core_ext/object.rb
sinclair-1.14.1 lib/sinclair/core_ext/object.rb
sinclair-1.14.0 lib/sinclair/core_ext/object.rb
sinclair-1.13.0 lib/sinclair/core_ext/object.rb