Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/null.rb
Instance Method Summary collapse
-
#! ⇒ Object
This is an alias for
falsy?. -
#falsy? ⇒ Boolean
falsy?istrueiff we arenil,false, or an instance of NullClass. -
#null? ⇒ Boolean
Are we
null?. -
#tap? {|_self| ... } ⇒ Boolean
obj.tap?() is equivalent to obj.tap() unless
objis an instance of NullClass, in which case a block must still be given, but will not be executed. -
#to_nil? ⇒ Boolean
null.to_nil?returnsnil; everything else returnsself. -
#to_null? ⇒ Boolean
void,nil, andnullreturnnull; everything else returnsself. -
#truthy? ⇒ Boolean
truthy?isfalseiff we arenil,false, or an instance of NullClass.
Instance Method Details
#falsy? ⇒ Boolean
falsy? is true iff we are nil, false, or an instance of NullClass.
8 9 10 |
# File 'lib/null.rb', line 8 def falsy? false end |
#null? ⇒ Boolean
Are we null?
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.
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.
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.
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.
3 4 5 |
# File 'lib/null.rb', line 3 def truthy? true end |