Sha256: 2959ec19963f77dde9497a07cdc1fae9c55deeeed5ad149cda3291c47b8b0b0a

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

class Proc < `Function`
  %x{
    Proc_prototype._isProc = true;
    Proc_prototype.is_lambda = true;
  }

  def self.new(&block)
    `if (block === nil) no_block_given();`
    `block.is_lambda = false`
    block
  end

  def call(*args)
    `#{self}.apply(null, #{args})`
  end

  def to_proc
    self
  end

  def lambda?
    # This method should tell the user if the proc tricks are unavailable,
    # (see Proc#lambda? on ruby docs to find out more).
    `!!#{self}.is_lambda`
  end

  def arity
    `this.length - 1`
  end
end

class Method < Proc; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.3.31 core/proc.rb