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



36
37
38
# File 'lib/nullobject.rb', line 36

def method_missing(*_args, &_block)
  self
end

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#inspectObject



32
33
34
# File 'lib/nullobject.rb', line 32

def inspect
  format("#<%s:0x%x>", self.class, object_id)
end

#nil?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/nullobject.rb', line 28

def nil?
  true
end

#respond_to?(_message, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/nullobject.rb', line 40

def respond_to?(_message, _include_private = false)
  true
end

#to_aObject



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

def to_a
  []
end

#to_aryObject



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

def to_ary
  []
end

#to_fObject



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

def to_f
  0.0
end

#to_iObject



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

def to_i
  0
end

#to_sObject



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

def to_s
  ""
end