Sha256: 29fe41f36f94619cd4e3018a9a790abd4714339e7172f59b0b3c12b7aaed6eac

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

class Boolean < `Boolean`
  %x{
    Boolean_prototype._isBoolean = true;
  }

  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 singleton_class class

  def to_json
    `#{self}.valueOf() ? 'true' : 'false'`
  end

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

TRUE  = true
FALSE = false

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-0.3.22 core/boolean.rb
opal-0.3.21 core/boolean.rb