Class: Proc
- Inherits:
-
Object
- Object
- Proc
- Defined in:
- opal/opal/corelib/proc.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#arity ⇒ Object
FIXME: this should support the various splats and optional arguments.
- #call(*args, &block) ⇒ Object (also: #[])
- #lambda? ⇒ Boolean
- #to_proc ⇒ Object
Class Method Details
.new(&block) ⇒ Object
5 6 7 8 9 10 11 |
# File 'opal/opal/corelib/proc.rb', line 5 def self.new(&block) unless block raise ArgumentError, "tried to create a Proc object without a block" end block end |
Instance Method Details
#arity ⇒ Object
FIXME: this should support the various splats and optional arguments
49 50 51 |
# File 'opal/opal/corelib/proc.rb', line 49 def arity `self.length` end |
#call(*args, &block) ⇒ Object Also known as: []
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'opal/opal/corelib/proc.rb', line 13 def call(*args, &block) %x{ if (block !== nil) { self._p = block; } var result; if (self.is_lambda) { result = self.apply(null, args); } else { result = Opal.$yieldX(self, args); } if (result === $breaker) { return $breaker.$v; } return result; } end |
#lambda? ⇒ Boolean
42 43 44 45 46 |
# File 'opal/opal/corelib/proc.rb', line 42 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 |
#to_proc ⇒ Object
38 39 40 |
# File 'opal/opal/corelib/proc.rb', line 38 def to_proc self end |