Module: Tins::Null

Included in:
NullClass
Defined in:
lib/tins/null.rb

Overview

Implementation of the null object pattern in Ruby.

Defined Under Namespace

Modules: Kernel

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject



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

def method_missing(*)
  self
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/tins/null.rb', line 48

def blank?
  true
end

#const_missingObject



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

def const_missing(*)
  self
end

#inspectObject



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

def inspect
  'NULL'
end

#nil?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/tins/null.rb', line 44

def nil?
  true
end

#to_aObject



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

def to_a
  []
end

#to_aryObject



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

def to_ary
  nil
end

#to_fObject



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

def to_f
  0.0
end

#to_iObject



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

def to_i
  0
end

#to_intObject



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

def to_int
  nil
end

#to_sObject



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

def to_s
  ''
end

#to_strObject



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

def to_str
  nil
end