有没有办法在 Opal 中使用 ruby Math 库?
在我的 ruby 方法中Uncaught NameError: uninitialized constant Object::Math
使用时收到以下错误消息。Math::PI
红宝石代码:
class Numeric
def degrees
self * Math::PI / 180
end
end
Opal 生成的 javascript :
/* Generated by Opal 0.6.3 */
(function($opal) {
var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice, $klass = $opal.klass;
$opal.add_stubs(['$/', '$*']);
return (function($base, $super) {
function $Numeric(){};
var self = $Numeric = $klass($base, $super, 'Numeric', $Numeric);
var def = self._proto, $scope = self._scope;
return (def.$degrees = function() {
var $a, $b, self = this;
return self['$*']((($a = ((($b = $scope.Math) == null ? $opal.cm('Math') : $b))._scope).PI == null ? $a.cm('PI') : $a.PI))['$/'](180);
}, nil) && 'degrees'
})(self, null)
})(Opal);
//# sourceMappingURL=/__opal_source_maps__/game_engine/numeric.js.map
;
谢谢 ;)