class NilClass
Constants
- MOBJ_NULL_REGION_BEGIN
- MOBJ_NULL_REGION_END
Public Instance Methods
__mobj__caller()
click to toggle source
# File lib/ext/nil.rb, line 6 def __mobj__caller() caller.find do |frame| (file, line) = frame.split(":") file != __FILE__ || !(MOBJ_NULL_REGION_BEGIN..MOBJ_NULL_REGION_END).cover?(line.to_i) end end
attempt(value=true)
click to toggle source
# File lib/ext/nil.rb, line 65 def attempt(value=true) Forwarder.new do |name, *args, &block| if self.methods(true).include? name self.__send__(name, *args, &block) elsif value.p? value.call([name] + args, &block) elsif value.h? && value.ki?(name) value[name].when.p?.call(*args, &block) else value end end end
fals?(val=nil, &block)
click to toggle source
# File lib/ext/nil.rb, line 21 def fals?(val=nil, &block) if block block.call(val) else val end end
iff?(_=nil)
click to toggle source
# File lib/ext/nil.rb, line 29 def iff?(_=nil) self end
iffn?(value = nil, &block)
click to toggle source
# File lib/ext/nil.rb, line 33 def iffn?(value = nil, &block) block ? instance_exec(value, &block) : value end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/ext/nil.rb, line 52 def method_missing(name, *args, &block) if null? self else nil! super end end
nil!(*)
click to toggle source
# File lib/ext/nil.rb, line 47 def nil!(*) @@null = nil self end
null!(*)
click to toggle source
# File lib/ext/nil.rb, line 42 def null!(*) @@null = __mobj__caller self end
Also aliased as: try?
null?(*)
click to toggle source
# File lib/ext/nil.rb, line 37 def null?(*) @@null ||= nil @@null && @@null == __mobj__caller end
tru?(_=nil, f=nil, &block)
click to toggle source
# File lib/ext/nil.rb, line 17 def tru?(_=nil, f=nil, &block) f end
zero?()
click to toggle source
# File lib/ext/nil.rb, line 13 def zero? true end