Class: Object

Inherits:
BasicObject
Defined in:
lib/null.rb

Instance Method Summary collapse

Instance Method Details

#!Object

This is an alias for falsy?.



13
14
15
# File 'lib/null.rb', line 13

def !()
  falsy?
end

#falsy?Boolean

falsy? is true iff we are nil, false, or an instance of NullClass.

Returns:

  • (Boolean)


8
9
10
# File 'lib/null.rb', line 8

def falsy?
  false
end

#null?Boolean

Are we null?

Returns:

  • (Boolean)


18
19
20
# File 'lib/null.rb', line 18

def null?
  false
end

#tap? {|_self| ... } ⇒ Boolean

obj.tap?() is equivalent to obj.tap() unless obj is an instance of NullClass, in which case a block must still be given, but will not be executed.

Yields:

  • (_self)

Yield Parameters:

  • _self (Object)

    the object that the method was called on

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/null.rb', line 35

def tap? # yield: self
  yield(self)
  self
end

#to_nil?Boolean

null.to_nil? returns nil; everything else returns self.

Returns:

  • (Boolean)


23
24
25
# File 'lib/null.rb', line 23

def to_nil?()
  self
end

#to_null?Boolean

void, nil, and null return null; everything else returns self.

Returns:

  • (Boolean)


28
29
30
# File 'lib/null.rb', line 28

def to_null?()
  self
end

#truthy?Boolean

truthy? is false iff we are nil, false, or an instance of NullClass.

Returns:

  • (Boolean)


3
4
5
# File 'lib/null.rb', line 3

def truthy?
  true
end