Class: KBNilClass

Inherits:
Object show all
Includes:
Comparable
Defined in:
lib/kirbybase.rb

Overview


KBNilClass


Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



3838
3839
3840
# File 'lib/kirbybase.rb', line 3838

def method_missing(sym, *args)
    kb_nil
end

Class Method Details

.newObject



3797
3798
3799
# File 'lib/kirbybase.rb', line 3797

def new
    @kb_nil ||= KBNilClass.allocate
end

Instance Method Details

#<=>(other) ⇒ Object



3826
3827
3828
3829
# File 'lib/kirbybase.rb', line 3826

def <=>(other)
    return 0 if other.kb_nil?
    return -1
end

#coerce(other) ⇒ Object



3831
3832
3833
3834
3835
3836
# File 'lib/kirbybase.rb', line 3831

def coerce(other)
    return [other, to_i] if other.kind_of? Fixnum
    return [other, to_f] if other.kind_of? Float

    raise "Didn't know how to coerce kb_nil to a #{other.class}"
end

#inspectObject



3802
3803
3804
# File 'lib/kirbybase.rb', line 3802

def inspect
    'kb_nil'
end

#kb_nil?Boolean

Returns:

  • (Boolean)


3806
3807
3808
# File 'lib/kirbybase.rb', line 3806

def kb_nil?
    true
end

#to_aObject



3822
3823
3824
# File 'lib/kirbybase.rb', line 3822

def to_a
    []
end

#to_fObject



3818
3819
3820
# File 'lib/kirbybase.rb', line 3818

def to_f
    0.0
end

#to_iObject



3814
3815
3816
# File 'lib/kirbybase.rb', line 3814

def to_i
    0
end

#to_sObject



3810
3811
3812
# File 'lib/kirbybase.rb', line 3810

def to_s
    ""
end