class NilClass

Core Extensions

Public Instance Methods

blank?() click to toggle source
# File lib/core/facets/blank.rb, line 20
def blank?
  true
end
clone?() click to toggle source
# File lib/core/facets/duplicable.rb, line 10
def clone? ; false ; end
dup?() click to toggle source
# File lib/core/facets/duplicable.rb, line 9
def dup?   ; false ; end
ergo() click to toggle source

Compliments Kernel#ergo.

"a".ergo{ |o| o.upcase } #=> "A"
nil.ergo{ |o| o.bar } #=> nil

CREDIT: Daniel DeLorme

# File lib/core/facets/kernel/ergo.rb, line 36
def ergo
  @_ergo ||= Functor.new{ nil }
  @_ergo unless block_given?
end
to_bool() click to toggle source
# File lib/core/facets/boolean.rb, line 153
def to_bool
  false
end
to_f() click to toggle source

Allows nil to respond to to_f. Always returns 0.

nil.to_f   #=> 0.0

CREDIT: Matz

# File lib/core/facets/nilclass/to_f.rb, line 12
def to_f; 0.0; end
to_h() click to toggle source

Allows nil to create an empty hash, similar to to_a and to_s.

nil.to_h    #=> {}

CREDIT: Trans

# File lib/core/facets/to_hash.rb, line 264
def to_h; {}; end
to_openobject() click to toggle source

Nil converts to an empty OpenObject.

# File lib/more/facets/openobject.rb, line 233
def to_openobject
  OpenObject.new
end
to_path() click to toggle source

Provide platform dependent null path.

CREDIT Daniel Burger

# File lib/more/facets/pathname.rb, line 175
def to_path
  Pathname.null
end