Example:
Ruby runtime = JavaEmbedUtils.initialize(List.of("a/custom/load/path"));
RubyRuntimeAdapter evaler = JavaEmbedUtils.newRuntimeAdapter();
IRubyObject rubyObject = evaler.parse(runtime, expr.toString(), file, line).run());
SomeClassOrInterface javaObject = JavaEmbedUtils.rubyToJava(rubyObject, SomeClassOrInterface.class);
runtime.terminate();
| Modifier and Type | Class and Description |
|---|---|
| public static interface | JavaEmbedUtils.
All implementers can be run and will return the last value in the evaluation unit. |
| public static class | JavaEmbedUtils.
An evaluation unit which is based on running JRuby's interpreter (as opposed to the compiler). |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static Ruby | Returns: an instanceto specify where to look for Ruby modules. loadPaths)Get an instance of a JRuby runtime. |
| public static Ruby | Returns: an instanceadditional load paths you wish to add loadPaths, RubyInstanceConfig a runtime configuration instance config)Get an instance of a JRuby runtime. |
| public static <T> T | Returns: the result of the invocation.environment where the invoke will occur runtime, Object is the instance that will receive the method call receiver, String is method to be called method, Object[] are the arguments to the method args, Class<T> is the type we want it to conform to returnType)Convenience function for embedders |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static RubyObjectAdapter | |
| public static RubyRuntimeAdapter | |
| public static <T> T | |
| public static <T> T | |
| public static <T> T | Returns: the converted objectto be converted value)Convert the Ruby object to a Java Object. |
| public static void |
| JavaEmbedUtils | back to summary |
|---|---|
| public JavaEmbedUtils() | |
| initialize | back to summary |
|---|---|
| public static Ruby initialize(List<String> loadPaths) Get an instance of a JRuby runtime. Provide any loadpaths you want used at startup. | |
| initialize | back to summary |
|---|---|
| public static Ruby initialize(List<String> loadPaths, RubyInstanceConfig config) Get an instance of a JRuby runtime.
| |
| invokeMethod | back to summary |
|---|---|
| public static <T> T invokeMethod(Ruby runtime, Object receiver, String method, Object[] args, Class<T> returnType) Convenience function for embedders
| |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, Object value) Convert a java object to a Ruby object.
| |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, boolean value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, byte value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, char value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, double value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, float value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, int value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, long value) | |
| javaToRuby | back to summary |
|---|---|
| public static IRubyObject javaToRuby(Ruby runtime, short value) | |
| newObjectAdapter | back to summary |
|---|---|
| public static RubyObjectAdapter newObjectAdapter() | |
| newRuntimeAdapter | back to summary |
|---|---|
| public static RubyRuntimeAdapter newRuntimeAdapter() | |
| rubyToJava | back to summary |
|---|---|
| public static <T> T rubyToJava(IRubyObject value, Class<T> type) Convert a Ruby object to a Java object. | |
| rubyToJava | back to summary |
|---|---|
| public static <T> T rubyToJava(Ruby runtime, IRubyObject value, Class<T> type) | |
| rubyToJava | back to summary |
|---|---|
| public static <T> T rubyToJava(IRubyObject value) Convert the Ruby object to a Java Object.
| |
| terminate | back to summary |
|---|---|
| public static void terminate(Ruby runtime) Dispose of the runtime you initialized.
| |
| Modifier and Type | Method and Description |
|---|---|
| public IRubyObject |
| run | back to summary |
|---|---|
public IRubyObject run()
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ParseResult | |
| private final Ruby |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public IRubyObject |
| result | back to summary |
|---|---|
| private final ParseResult result | |
| runtime | back to summary |
|---|---|
| private final Ruby runtime | |
| InterpretedEvalUnit | back to summary |
|---|---|
| protected InterpretedEvalUnit(Ruby runtime, ParseResult result) | |
| InterpretedEvalUnit | back to summary |
|---|---|
| protected InterpretedEvalUnit(Ruby runtime, Node node)
Deprecated
| |
| run | back to summary |
|---|---|
| public IRubyObject run() Implements org.
| |