ITコンサルの日常

ITコンサル会社に勤務する普通のITエンジニアの日常です。

JavaからFixturesを使ってみる - ちょっとだけすっきり書けた

import java.io.FileInputStream;
import org.jruby.Ruby;
import org.jruby.runtime.Block;

public class CallRuby
{
	public static void main(String[] args) throws Exception
	{
		Ruby runtime = Ruby.newInstance();
		runtime.parseFile(
			new FileInputStream("hoge.rb")
			, "<hoge>"
			, runtime.getCurrentContext().getCurrentScope()
		).interpret(
			runtime
			, runtime.getCurrentContext()
			, runtime.getCurrentContext().getFrameSelf()
			, Block.NULL_BLOCK
		);
	}
}

引数は無理矢理文字列組み立てればできないことはないけど、戻り値はどうやって取得するのだろうか。。