JRuby

「JRuby」の編集履歴(バックアップ)一覧はこちら

JRuby」(2010/11/16 (火) 15:10:55) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

参考 http://kenai.com/projects/jruby/pages/RedBridge ・require と クラスパス JRubyの require の検索は Javaのクラスパスを用いる require 'erb' とある場合は、Javaのクラスパスのデフォルトパッケージ内に、erb.rb が含まれていれば良い。 require 'com/xxx/mylib' とある場合は、Javaのクラスパスのcom.xxxパッケージ内に、mylib.rb が含まれていれば良い。 ・サンプル public static void main(String[] args) throws FileNotFoundException { scriptHelloWorld(); scriptHelloWorld2(); scriptHelloWorldFromFile(); } private static void scriptHelloWorld() { ScriptingContainer container = new ScriptingContainer(); container.runScriptlet("puts \"Hello World!\""); } private static void scriptHelloWorld2() { ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.PERSISTENT); container.runScriptlet("word = 'hello JRuby!'"); container.runScriptlet("puts word"); } private static void scriptHelloWorldFromFile() throws FileNotFoundException { ScriptingContainer container = new ScriptingContainer(); container.runScriptlet(new FileInputStream(new File("helloworld.rb")), ""); } --------
参考 http://kenai.com/projects/jruby/pages/RedBridge ・require と クラスパス JRubyの require の検索は Javaのクラスパスを用いる require 'erb' とある場合は、Javaのクラスパスのデフォルトパッケージ内に、erb.rb が含まれていれば良い。 require 'com/xxx/mylib' とある場合は、Javaのクラスパスのcom.xxxパッケージ内に、mylib.rb が含まれていれば良い。 ・サンプル public static void main(String[] args) throws FileNotFoundException { scriptHelloWorld(); scriptHelloWorld2(); scriptHelloWorldFromFile(); } private static void scriptHelloWorld() { ScriptingContainer container = new ScriptingContainer(); container.runScriptlet("puts \"Hello World!\""); } private static void scriptHelloWorld2() { ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.PERSISTENT); container.runScriptlet("word = 'hello JRuby!'"); container.runScriptlet("puts word"); } private static void scriptHelloWorldFromFile() throws FileNotFoundException { ScriptingContainer container = new ScriptingContainer(); container.runScriptlet(new FileInputStream(new File("helloworld.rb")), ""); } -------- #配列 array = Array.new #ハッシュ hash = Hash.new hash['a'] = 'A' # A が表示される puts hash['a'] --------

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。