Sha256: 3c96c447eef1a7ee79dd6f2b63d543624bbe9bebd1ee115e5459d46fcbff94f6

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

# = NullClass
#
# NullClass is essentially NilClass but it differs in one
# important way. When a method is called against it that it
# deoesn't have, it will simply return null value rather then
# raise an error.s
#
# == Authors
#
# * Thomas Sawyer
#
# = Copying
#
# Copyright (c) 2005 Thomas Sawyer
#
# Ruby License
#
# This module is free software. You may use, modify, and/or redistribute this
# software under the same terms as Ruby.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.

# = Nullclass
#
# NullClass is essentially NilClass but it differs in one
# important way. When a method is called against it that it
# deoesn't have, it will simply return null value rather then
# raise an error.
#
# TODO: Perhaps NullClass and NackClass should be one and the same?
#
class NullClass #< NilClass
  class << self
    def new
      @null ||= NullClass.allocate
    end
  end
  def inspect ; 'null' ; end
  def nil?  ; true ; end
  def null? ; true ; end
  def [](key); nil; end
  def method_missing(sym, *args)
    return nil if sym.to_s[-1,1] == '?'
    self
  end
end

module Kernel
  def null
    NullClass.new
  end
end

class Object
  def null?
    false
  end
end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#

# TODO

=begin #testing
=end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
facets-2.8.4 lib/more/facets/nullclass.rb
facets-2.8.3 lib/more/facets/nullclass.rb
facets-2.8.2 lib/more/facets/nullclass.rb
facets-2.8.1 lib/more/facets/nullclass.rb
facets-2.8.0 lib/more/facets/nullclass.rb
facets-2.7.0 lib/more/facets/nullclass.rb
facets-2.6.0 lib/more/facets/nullclass.rb
facets-2.4.0 lib/facets/nullclass.rb
facets-2.4.1 lib/facets/nullclass.rb
facets-2.4.3 lib/more/facets/nullclass.rb
facets-2.4.4 lib/more/facets/nullclass.rb
facets-2.4.2 lib/more/facets/nullclass.rb
facets-2.5.1 lib/more/facets/nullclass.rb
facets-2.4.5 lib/more/facets/nullclass.rb
facets-2.5.0 lib/more/facets/nullclass.rb
facets-2.5.2 lib/more/facets/nullclass.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/more/facets/nullclass.rb