Sha256: 2a766079dba47b4e4862d7c4fa4959f26b8f2c13c2105d76aed68f21ba17f10a

Contents?: true

Size: 1014 Bytes

Versions: 13

Compression:

Stored size: 1014 Bytes

Contents

class Boolean < `Boolean`
  `Opal.defineProperty(self.$$prototype, '$$is_boolean', true)`
  `Opal.defineProperty(self.$$prototype, '$$meta', #{self})`

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

    undef :new
  end

  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
    self
  end

  def clone(freeze: true)
    self
  end
end

TrueClass  = Boolean
FalseClass = Boolean

TRUE  = true
FALSE = false

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
opal-1.2.0 opal/corelib/boolean.rb
opal-1.2.0.beta1 opal/corelib/boolean.rb
opal-1.1.1 opal/corelib/boolean.rb
opal-1.1.1.rc1 opal/corelib/boolean.rb
opal-1.1.0 opal/corelib/boolean.rb
opal-1.1.0.rc1 opal/corelib/boolean.rb
opal-1.0.5 opal/corelib/boolean.rb
opal-1.0.4 opal/corelib/boolean.rb
opal-1.0.3 opal/corelib/boolean.rb
opal-1.0.2 opal/corelib/boolean.rb
opal-1.0.1 opal/corelib/boolean.rb
opal-1.0.0 opal/corelib/boolean.rb
opal-1.0.0.beta1 opal/corelib/boolean.rb