Module: Kernel

Defined in:
lib/assay/core_ext/kernel.rb

Instance Method Summary collapse

Instance Method Details

#boolean?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/assay/core_ext/kernel.rb', line 48

def boolean?
  true? || false?
end

#false?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/assay/core_ext/kernel.rb', line 43

def false?
  FalseClass === self
end

#identical?(other) ⇒ Boolean

Do two references have the same ‘#object_id`, and hence are the same object.

Parameters:

  • other (Object)

    Any object reference.

Returns:

  • (Boolean)


9
10
11
# File 'lib/assay/core_ext/kernel.rb', line 9

def identical?(other)
  object_id == other.object_id
end

#like?(other) ⇒ Boolean

TODO:

Should ‘#=~` be apart of this comparison?

Ascertain likeness, returns true if any of ‘equal?`, `eql?`, `==`, `===` or `=~` evaluate truthfully, either with `self` as the receiver or `other` as the receiver.

Parameters:

  • other (Object)

    Any object reference.

Returns:

  • (Boolean)

    true if alike.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/assay/core_ext/kernel.rb', line 24

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

#true?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/assay/core_ext/kernel.rb', line 38

def true?
  TrueClass === self
end