public
Description: Mozilla JavaScript Engine (SpiderMonkey) bindings for Ruby
Clone URL: git://github.com/matthewd/ruby-mozjs.git
Function#to_proc
wycats (author)
Wed Apr 16 18:49:25 -0700 2008
commit  0a6ebefdb20b9a23f8f1bfa2ac570970fb88796b
tree    cfb02863ceac3a6b8e70c2fa1f96919e0abf4b61
parent  01453412474545670add5af36683117e11f4d2d4
...
18
19
20
 
 
 
 
 
 
 
 
21
22
23
...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -18,6 +18,14 @@ end
0
 
0
 class SpiderMonkey::Value
0
   
0
+ def to_proc
0
+ if typeof == "function"
0
+ proc {|*args| self.call_function("call", self, *args) }
0
+ else
0
+ raise TypeError, "You cannot convert a #{typeof} to a proc"
0
+ end
0
+ end
0
+
0
   def method_missing(meth, *args)
0
     if val = meth.to_s.match(/^(.*)=$/)
0
       set_property(val[1], *args)

Comments

    No one has commented yet.