[英]how can get proc content using Opalrb parser
I need to get the content of a proc send to js by Opal ruby.我需要通过 Opal ruby 获取 proc 的内容发送到 js。 I am only using the static version of Opal, Opal-native, opal-parser.
我只使用 Opal、Opal-native、opal-parser 的 static 版本。 how can I proceed?
我该如何进行?
def parse_proc params
#### how can I get proc content?
end
def touch(&proc)
parse_proc proc
end
b=box()
c=circle()
b.touch do
b.color(:red)
c.x=200
end
I found a solution I think there must be an better way but it works:我找到了一个解决方案,我认为必须有更好的方法,但它有效:
def analysis_of_proc params
the_proc_conent_is=`the_proc_conent_is = #{params}.toString();`
puts the_proc_conent_is
end
def my_proc(&proc)
analysis_of_proc proc
proc.call
end
my_proc do
a="hello"
b="world"
def add_word fist, second
return fist+" "+second
end
add_word a,b
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.