Ruby/JS Javascript engine for Ruby

This is Ruby Extension for Using NJS Javascript Interpreter <URL:http://www.bbassett.net/njs/>

current Version(0.0.4) feature this:

% ruby -rjs -e 'p JS::evaluate(%!true!)'
true
% ruby -rjs -e 'p JS::evaluate(%!Math.PI!)'
3.141592654
% ruby -rjs -e 'p JS::evaluate(%q!new Date().toString()!)'
"Mon Feb 24 12:39:15 2003"
% ruby -r./js -e \
   'js = JS.new;p js.eval("a = new Array(5); a.length;"); \
    p js.eval("a.toString()")'
5
"undefined,undefined,undefined,undefined,undefined"
% ruby -r./js -e \
   'js = JS.new;p js.eval(%q!a = new Array("a","b","cc",new Array(1,2,3.1414));!)' 
["a", "b", "cc", [1, 2, 3.1414]]

I reference

Install

Require NJS(tested 0.2.5). and

% ruby extconf.rb
% make
% sudo make install

Reference

JS class

Class Method:

JS.evaluate(code)

eval Javascript code and return value. raise JSError exception when error.

JS.new()

create Javascript Interpreter.

JS#eval(code)

eval code and return value by Interpreter instance. raise JSError exception when error.

Constants:

JS::LIB_VERSION

NJS's Version string return.

JSError class

sub class of StandardError.

Copying

No warranties, GPL2 license. see js.c

ChangeLog

Sat Mar 11 00:00:00 2003

Sat Feb 29 00:00:00 2003

Wed Feb 26 18:00:00 2003

Mon Feb 24 18:00:00 2003

Sun Feb 23 18:00:00 2003

TAMURA.Kenichi tamura@ruby-lang.org