Sha256: 7366a6f819919404565ab9f8736757871d643cc33abe34c23ee1886b545fa891

Contents?: true

Size: 660 Bytes

Versions: 9

Compression:

Stored size: 660 Bytes

Contents

class Boolean
  `def.$$is_boolean = 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

9 entries across 9 versions & 2 rubygems

Version Path
opal-0.7.2 opal/corelib/boolean.rb
opal-0.7.1 opal/corelib/boolean.rb
opal-0.7.0 opal/corelib/boolean.rb
opal-0.7.0.rc1 opal/corelib/boolean.rb
opal-0.7.0.beta3 opal/corelib/boolean.rb
opal-0.7.0.beta2 opal/corelib/boolean.rb
opal-cj-0.7.0.beta2 opal/corelib/boolean.rb
opal-cj-0.7.0.beta1 opal/corelib/boolean.rb
opal-0.7.0.beta1 opal/corelib/boolean.rb