Class: NilClass

Inherits:
Object
  • Object
show all
Defined in:
documented/common/class_exts/nilclass.rb

Overview

Represents the NilClass, which is the class of the nil object.

This class provides methods that return nil or behave as if they are nil.

See Also:

  • Object

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*_args) ⇒ nil

Handles calls to methods that do not exist on the nil object.

Parameters:

  • args (Array)

    the arguments passed to the missing method

Returns:

  • (nil)


16
17
18
# File 'documented/common/class_exts/nilclass.rb', line 16

def method_missing(*_args)
  nil
end

Instance Method Details

#+(val) ⇒ Object

Adds the nil object to another value.

Parameters:

  • val (Object)

    the value to add

Returns:

  • (Object)

    the value passed in



42
43
44
# File 'documented/common/class_exts/nilclass.rb', line 42

def +(val)
  val
end

#closed?Boolean

Checks if the nil object is considered closed.

Returns:

  • (Boolean)

    always returns true



48
49
50
# File 'documented/common/class_exts/nilclass.rb', line 48

def closed?
  true
end

#dupnil

Returns a duplicate of the nil object.

Returns:

  • (nil)


9
10
11
# File 'documented/common/class_exts/nilclass.rb', line 9

def dup
  nil
end

#split(*_val) ⇒ Array

Splits the nil object into an array.

Parameters:

  • val (Array)

    the delimiter(s) to split by

Returns:

  • (Array)

    an empty array



23
24
25
# File 'documented/common/class_exts/nilclass.rb', line 23

def split(*_val)
  Array.new
end

#stripString

Removes whitespace from the nil object.

Returns:

  • (String)

    an empty string



35
36
37
# File 'documented/common/class_exts/nilclass.rb', line 35

def strip
  ""
end

#to_sString

Converts the nil object to a string.

Returns:

  • (String)

    an empty string



29
30
31
# File 'documented/common/class_exts/nilclass.rb', line 29

def to_s
  ""
end