Module: Null

Included in:
Object
Defined in:
lib/nullobject.rb

Defined Under Namespace

Classes: Object

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



20
21
22
# File 'lib/nullobject.rb', line 20

def method_missing(*args, &block)
  self
end

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/nullobject.rb', line 5

def self.included(base)
  base.send(:include, Singleton)
end

Instance Method Details

#inspectObject



16
17
18
# File 'lib/nullobject.rb', line 16

def inspect
  "#<%s:0x%x>" % [self.class, object_id]
end

#nil?Boolean

Returns:

  • (Boolean)


14
# File 'lib/nullobject.rb', line 14

def nil?; true; end

#respond_to?(message, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/nullobject.rb', line 24

def respond_to?(message, include_private=false)
  true
end

#to_aObject



9
# File 'lib/nullobject.rb', line 9

def to_a; []; end

#to_aryObject



10
# File 'lib/nullobject.rb', line 10

def to_ary; []; end

#to_fObject



12
# File 'lib/nullobject.rb', line 12

def to_f; 0.0; end

#to_iObject



13
# File 'lib/nullobject.rb', line 13

def to_i; 0; end

#to_sObject



11
# File 'lib/nullobject.rb', line 11

def to_s; ""; end