Class: NilClass

Inherits:
Object show all
Defined in:
opal/opal/corelib/nil.rb,
opal/opal/corelib/marshal/write_buffer.rb

Overview

backtick_javascript: true

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allocateObject



7
8
9
# File 'opal/opal/corelib/nil.rb', line 7

def allocate
  ::Kernel.raise ::TypeError, "allocator undefined for #{name}"
end

Instance Method Details

#!Object



14
15
16
# File 'opal/opal/corelib/nil.rb', line 14

def !
  true
end

#&(other) ⇒ Object



18
19
20
# File 'opal/opal/corelib/nil.rb', line 18

def &(other)
  false
end

#==(other) ⇒ Object



30
31
32
# File 'opal/opal/corelib/nil.rb', line 30

def ==(other)
  `other === nil`
end

#^(other) ⇒ Object



26
27
28
# File 'opal/opal/corelib/nil.rb', line 26

def ^(other)
  `other !== false && other !== nil`
end

#__marshal__(buffer) ⇒ Object



4
5
6
# File 'opal/opal/corelib/marshal/write_buffer.rb', line 4

def __marshal__(buffer)
  buffer.append('0')
end

#clone(freeze: true) ⇒ Object



38
39
40
# File 'opal/opal/corelib/nil.rb', line 38

def clone(freeze: true)
  nil
end

#dupObject



34
35
36
# File 'opal/opal/corelib/nil.rb', line 34

def dup
  nil
end

#inspectObject



42
43
44
# File 'opal/opal/corelib/nil.rb', line 42

def inspect
  'nil'
end

#instance_variablesObject



83
84
85
# File 'opal/opal/corelib/nil.rb', line 83

def instance_variables
  []
end

#nil?Boolean

Returns:



46
47
48
# File 'opal/opal/corelib/nil.rb', line 46

def nil?
  true
end

#rationalize(*args) ⇒ Object



74
75
76
77
# File 'opal/opal/corelib/nil.rb', line 74

def rationalize(*args)
  ::Kernel.raise ::ArgumentError if args.length > 1
  ::Kernel.Rational(0, 1)
end

#singleton_classObject



50
51
52
# File 'opal/opal/corelib/nil.rb', line 50

def singleton_class
  ::NilClass
end

#to_aObject



54
55
56
# File 'opal/opal/corelib/nil.rb', line 54

def to_a
  []
end

#to_cObject



70
71
72
# File 'opal/opal/corelib/nil.rb', line 70

def to_c
  ::Complex.new(0, 0)
end

#to_hObject



58
59
60
# File 'opal/opal/corelib/nil.rb', line 58

def to_h
  `new Map()`
end

#to_iObject Also known as: to_f



62
63
64
# File 'opal/opal/corelib/nil.rb', line 62

def to_i
  0
end

#to_rObject



79
80
81
# File 'opal/opal/corelib/nil.rb', line 79

def to_r
  ::Kernel.Rational(0, 1)
end

#to_sObject



66
67
68
# File 'opal/opal/corelib/nil.rb', line 66

def to_s
  ''
end

#|(other) ⇒ Object



22
23
24
# File 'opal/opal/corelib/nil.rb', line 22

def |(other)
  `other !== false && other !== nil`
end