Sha256: ffeeb15341a9bc03c46f54b005973bfb97782694116f542ca5f713a81295a590

Contents?: true

Size: 987 Bytes

Versions: 2

Compression:

Stored size: 987 Bytes

Contents

module Kernel

  # Do two references have the same `#object_id`, and hence are the
  # same object.
  #
  # @param [Object] other
  #   Any object reference.
  #
  def identical?(other)
    object_id == other.object_id
  end

  # Ascertain likeness, returns true if any of `equal?`, `eql?`, `==`,
  # `===` or `=~` evaluate truthfully, either with `self` as the receiver
  # or `other` as the receiver.
  #
  # @todo Should `#=~` be apart of this comparison?
  #
  # @param [Object] other
  #   Any object reference.
  #
  # @return [Boolean] +true+ if alike.
  #
  def like?(other)
    self.equal?(other) ||
    self.eql?(other)   ||
    self.==(other)     ||
    self.===(other)    ||
    self.=~(other)     ||
    other.equal?(self) ||
    other.eql?(self)   ||
    other.==(self)     ||
    other.===(self)    ||
    other.=~(self)
  end

  #
  def true?
    TrueClass === self
  end

  #
  def false?
    FalseClass === self
  end

  #
  def boolean?
    true? || false?
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assay-0.4.1 lib/assay/core_ext/kernel.rb
assay-0.4.0 lib/assay/core_ext/kernel.rb