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



3860
3861
3862
3863
3864
3865
3866
3867
# File 'lib/kirbybase.rb', line 3860

def method_missing(sym, *args)
    case sym
    when :to_str, :to_ary
      super
    else
      self
    end
end

Class Method Details

.new ⇒ Object



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

def new
    @kb_nil ||= KBNilClass.allocate
end

Instance Method Details

#<=>(other) ⇒ Object



3848
3849
3850
3851
# File 'lib/kirbybase.rb', line 3848

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

#coerce(other) ⇒ Object



3853
3854
3855
3856
3857
3858
# File 'lib/kirbybase.rb', line 3853

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

#inspect ⇒ Object



3824
3825
3826
# File 'lib/kirbybase.rb', line 3824

def inspect
    'kb_nil'
end

#kb_nil? ⇒ Boolean

Returns:

  • (Boolean)


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

def kb_nil?
    true
end

#to_a ⇒ Object



3844
3845
3846
# File 'lib/kirbybase.rb', line 3844

def to_a
    []
end

#to_f ⇒ Object



3840
3841
3842
# File 'lib/kirbybase.rb', line 3840

def to_f
    0.0
end

#to_i ⇒ Object



3836
3837
3838
# File 'lib/kirbybase.rb', line 3836

def to_i
    0
end

#to_s ⇒ Object



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

def to_s
    ""
end