Class: NilClass

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

Instance Method Summary collapse

Instance Method Details

#!Object

[View source]

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

def !
  true
end

#&(other) ⇒ Object

[View source]

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

def &(other)
  false
end

#==(other) ⇒ Object

[View source]

20
21
22
# File 'opal/opal/corelib/nil.rb', line 20

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

#^(other) ⇒ Object

[View source]

16
17
18
# File 'opal/opal/corelib/nil.rb', line 16

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

#__marshal__(buffer) ⇒ Object

[View source]

2
3
4
# File 'opal/opal/corelib/marshal/write_buffer.rb', line 2

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

#cloneObject

Raises:

[View source]

28
29
30
# File 'opal/opal/corelib/nil.rb', line 28

def clone
  raise TypeError, "can't clone #{self.class}"
end

#dupObject

Raises:

[View source]

24
25
26
# File 'opal/opal/corelib/nil.rb', line 24

def dup
  raise TypeError, "can't dup #{self.class}"
end

#inspectObject

[View source]

32
33
34
# File 'opal/opal/corelib/nil.rb', line 32

def inspect
  'nil'
end

#instance_variablesObject

[View source]

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

def instance_variables
  []
end

#nil?Boolean

Returns:

[View source]

36
37
38
# File 'opal/opal/corelib/nil.rb', line 36

def nil?
  true
end

#rationalize(*args) ⇒ Object

Raises:

[View source]

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

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

#singleton_classObject

[View source]

40
41
42
# File 'opal/opal/corelib/nil.rb', line 40

def singleton_class
  NilClass
end

#to_aObject

[View source]

44
45
46
# File 'opal/opal/corelib/nil.rb', line 44

def to_a
  []
end

#to_cObject

[View source]

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

def to_c
  Complex.new(0, 0)
end

#to_hObject

[View source]

48
49
50
# File 'opal/opal/corelib/nil.rb', line 48

def to_h
  `Opal.hash()`
end

#to_iObject Also known as: to_f

[View source]

52
53
54
# File 'opal/opal/corelib/nil.rb', line 52

def to_i
  0
end

#to_rObject

[View source]

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

def to_r
  Rational(0, 1)
end

#to_sObject

[View source]

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

def to_s
  ''
end

#|(other) ⇒ Object

[View source]

12
13
14
# File 'opal/opal/corelib/nil.rb', line 12

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