org.mentawai.jruby
Class JRubyInterpreter

java.lang.Object
  extended by org.mentawai.jruby.JRubyInterpreter
All Implemented Interfaces:
Runnable

public class JRubyInterpreter
extends Object
implements Runnable


Field Summary
static long RELOAD_INTERVAL
           
 
Method Summary
 Object call(Object rubyObject, String methodName)
          Call a method on a Ruby object.
 Object call(Object rubyObject, String methodName, Class<? extends Object> returnType)
          Call a method on a Ruby object.
 Object call(Object rubyObject, String methodName, Class<? extends Object> returnType, Object... params)
          Call a method on a Ruby object passing some arguments to the ruby side.
 Object call(Object rubyObject, String methodName, Object... params)
          Call a method on a Ruby object passing some arguments to the ruby side.
 String callAction(Object rubyObject, String methodName)
           
 void close()
           
 org.jruby.RubyObject eval(String code)
           
static JRubyInterpreter getInstance()
           
 org.jruby.Ruby getRuntime()
           
 List<String> getSetters(Object rubyObject)
          Return a list of all setters for this ruby object.
static boolean isInitialized()
           
 void loadFileFromClasspath(String filename)
           
 void require(String file)
           
 boolean respondTo(Object rubyObject, String methodName)
          Call Ruby's respond_to? to find out if the Ruby object responds to a method.
 void run()
           
 Object set(Object rubyObject, String propName, Object value)
          Call a setter for this property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELOAD_INTERVAL

public static long RELOAD_INTERVAL
Method Detail

run

public void run()
Specified by:
run in interface Runnable

close

public void close()

getSetters

public List<String> getSetters(Object rubyObject)
Return a list of all setters for this ruby object. A Ruby setter has the form of name= (ends with =)

Parameters:
rubyObject - the ruby object from where to get the setters
Returns:
A list of setters (method names)

require

public void require(String file)

eval

public org.jruby.RubyObject eval(String code)

callAction

public String callAction(Object rubyObject,
                         String methodName)

call

public Object call(Object rubyObject,
                   String methodName)
Call a method on a Ruby object. (no arguments)

Parameters:
rubyObject - The ruby object in the Java side
methodName - The name of the method to call
Returns:
Any object created and returned by the method

call

public Object call(Object rubyObject,
                   String methodName,
                   Class<? extends Object> returnType)
Call a method on a Ruby object. (no arguments but forcing the return type)

Parameters:
rubyObject - The ruby object in the Java side
methodName - The name of the method to call
returnType - The return type for the return value of the method
Returns:
Any object created and returned by the method

call

public Object call(Object rubyObject,
                   String methodName,
                   Object... params)
Call a method on a Ruby object passing some arguments to the ruby side.

Parameters:
rubyObject - The ruby object in the Java side
methodName - The name of the method to call
params - The arguments to pass to the method
Returns:
Any object created and returned by the method

call

public Object call(Object rubyObject,
                   String methodName,
                   Class<? extends Object> returnType,
                   Object... params)
Call a method on a Ruby object passing some arguments to the ruby side. (force the return type)

Parameters:
rubyObject - The ruby object in the Java side
methodName - The name of the method to call
returnType - The return type for the return value of the method
params - The arguments to pass to the method
Returns:
Any object created and returned by the method

set

public Object set(Object rubyObject,
                  String propName,
                  Object value)
Call a setter for this property. It just appends '=' to construct the method name to use for the setter. Ex: set(rubyObject, "name", "hi") is equivalent to call(rubyObject, "name=", "hi")

Parameters:
rubyObject - The ruby object in the Java side
propName - The name of the property to set
value - The value of the property
Returns:
Any object created and returned by the method

respondTo

public boolean respondTo(Object rubyObject,
                         String methodName)
Call Ruby's respond_to? to find out if the Ruby object responds to a method.

Parameters:
rubyObject - The ruby object in the Java side
methodName - The method name
Returns:
true if the ruby object responds to that method

isInitialized

public static boolean isInitialized()

getInstance

public static JRubyInterpreter getInstance()

loadFileFromClasspath

public void loadFileFromClasspath(String filename)
                           throws IOException
Throws:
IOException

getRuntime

public org.jruby.Ruby getRuntime()


Copyright © 2013. All Rights Reserved.