Class: Boolean

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allocateObject

Raises:



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

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

Instance Method Details

#!Object



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

def !
  `self != true`
end

#&(other) ⇒ Object



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?



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

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

#^(other) ⇒ Object



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



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

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

#__marshal__(buffer) ⇒ Object



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



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

def clone(freeze: true)
  self
end

#dupObject



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

def dup
  self
end

#singleton_classObject



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

def singleton_class
  Boolean
end

#to_sObject



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

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

#|(other) ⇒ Object



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

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