Sha256: 2557c8c0e62930dc5fbebb84924df90fe7d3da5a858197692a953b4dda3b9175

Contents?: true

Size: 885 Bytes

Versions: 23

Compression:

Stored size: 885 Bytes

Contents

class Boolean < `Boolean`
  `def.$$is_boolean = true`
  `def.$$meta = #{self}`

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

  alias object_id __id__

  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 eql? ==

  def singleton_class
    Boolean
  end

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

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

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

TrueClass  = Boolean
FalseClass = Boolean

TRUE  = true
FALSE = false

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.10.6 opal/corelib/boolean.rb
opal-0.10.6.beta opal/corelib/boolean.rb
opal-0.10.5 opal/corelib/boolean.rb
opal-0.10.4 opal/corelib/boolean.rb
opal-0.11.0.rc1 opal/corelib/boolean.rb
opal-0.10.3 opal/corelib/boolean.rb
opal-0.10.2 opal/corelib/boolean.rb
opal-0.10.1 opal/corelib/boolean.rb
opal-0.10.0 opal/corelib/boolean.rb
opal-0.10.0.rc2 opal/corelib/boolean.rb
opal-0.9.4 opal/corelib/boolean.rb
opal-0.9.3 opal/corelib/boolean.rb
opal-0.10.0.rc1 opal/corelib/boolean.rb
opal-0.10.0.beta5 opal/corelib/boolean.rb
opal-0.10.0.beta4 opal/corelib/boolean.rb
opal-0.10.0.beta3 opal/corelib/boolean.rb
opal-0.10.0.beta2 opal/corelib/boolean.rb
opal-0.10.0.beta1 opal/corelib/boolean.rb
opal-0.9.2 opal/corelib/boolean.rb
opal-0.9.0 opal/corelib/boolean.rb