Sha256: c195d1619577f527782cf0a06ba8309122ba9486ab1614ae05bffb213dd6c5db

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

class Boolean
  `def.$$is_boolean = true`

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

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

  alias singleton_class class

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

TrueClass  = Boolean
FalseClass = Boolean

TRUE  = true
FALSE = false

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-wedge-0.9.0.dev opal/corelib/boolean.rb