Sha256: 7c9060080d9246fc1de5be8c56dfd2432d844ca14e931764ffa6acde2c73c42d

Contents?: true

Size: 658 Bytes

Versions: 4

Compression:

Stored size: 658 Bytes

Contents

class Boolean
  `def._isBoolean = true`

  class << self
    undef_method :new
  end

  def !
    `self != true`
  end

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

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

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

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

  alias equal? ==

  alias singleton_class class

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

TrueClass  = Boolean
FalseClass = Boolean

TRUE  = true
FALSE = false

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-0.6.3 opal/corelib/boolean.rb
opal-0.6.2 opal/corelib/boolean.rb
opal-0.6.1 opal/corelib/boolean.rb
opal-0.6.0 opal/corelib/boolean.rb