Class: Boolean

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allocateObject

Raises:

[View source]

6
7
8
# File 'opal/opal/corelib/boolean.rb', line 6

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

Instance Method Details

#!Object

[View source]

19
20
21
# File 'opal/opal/corelib/boolean.rb', line 19

def !
  `self != true`
end

#&(other) ⇒ Object

[View source]

23
24
25
# File 'opal/opal/corelib/boolean.rb', line 23

def &(other)
  `(self == true) ? (other !== false && other !== nil) : false`
end

#==(other) ⇒ Object Also known as: equal?, eql?

[View source]

35
36
37
# File 'opal/opal/corelib/boolean.rb', line 35

def ==(other)
  `(self == true) === other.valueOf()`
end

#^(other) ⇒ Object

[View source]

31
32
33
# File 'opal/opal/corelib/boolean.rb', line 31

def ^(other)
  `(self == true) ? (other === false || other === nil) : (other !== false && other !== nil)`
end

#__id__Object Also known as: object_id

[View source]

13
14
15
# File 'opal/opal/corelib/boolean.rb', line 13

def __id__
  `self.valueOf() ? 2 : 0`
end

#__marshal__(buffer) ⇒ Object

[View source]

8
9
10
11
12
13
14
# File 'opal/opal/corelib/marshal/write_buffer.rb', line 8

def __marshal__(buffer)
  if `self`
    buffer.append('T')
  else
    buffer.append('F')
  end
end

#clone(freeze: true) ⇒ Object

[View source]

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

def clone(freeze: true)
  self
end

#dupObject

[View source]

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

def dup
  self
end

#singleton_classObject

[View source]

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

def singleton_class
  Boolean
end

#to_sObject

[View source]

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

def to_s
  `(self == true) ? 'true' : 'false'`
end

#|(other) ⇒ Object

[View source]

27
28
29
# File 'opal/opal/corelib/boolean.rb', line 27

def |(other)
  `(self == true) ? true : (other !== false && other !== nil)`
end