org.jruby
Class Ruby

java.lang.Object
  extended byorg.jruby.Ruby

public final class Ruby
extends java.lang.Object

The jruby runtime.

Since:
0.1
Version:
$Revision: 1.41 $
Author:
jpetersen

Field Summary
 RubyFixnum[] fixnumCache
           
 ObjectSpace objectSpace
           
 java.util.Random random
           
 long randomSeed
           
 int stackTraces
           
 RubySymbol.SymbolTable symbolTable
           
 
Method Summary
 CallbackFactory callbackFactory()
           
 void callTraceFunction(java.lang.String event, ISourcePosition position, IRubyObject self, java.lang.String name, IRubyObject type)
          Call the trace function MRI: eval.c - call_trace_func
 RubyClass defineClass(java.lang.String name, RubyClass superClass)
          Define a new class with name 'name' and super class 'superClass'.
 RubyClass defineClassUnder(java.lang.String name, RubyClass superClass, RubyModule parentClass)
           
 void defineGlobalConstant(java.lang.String name, IRubyObject value)
          rb_define_global_const
 RubyModule defineModule(java.lang.String name)
          rb_define_module / rb_define_module_id
 RubyModule defineModuleUnder(java.lang.String name, RubyModule parentModule)
           
 void defineReadonlyVariable(java.lang.String name, IRubyObject value)
          defines a readonly global variable
 void defineVariable(GlobalVariable variable)
          Defines a global variable
 IRubyObject eval(INode node)
           
 IRubyObject evalScript(java.lang.String script)
          Evaluates a script and returns a RubyObject.
 java.lang.Object evalScript(java.lang.String script, java.lang.Class returnClass)
          Deprecated. If anyone actually uses this method then speak up now!
 IRubyObject getBackref()
           
 BlockStack getBlockStack()
           
 RubyClass getClass(java.lang.String name)
          Returns a class from the instance pool.
 RubyClasses getClasses()
           
 ThreadContext getCurrentContext()
           
 Frame getCurrentFrame()
           
 Visibility getCurrentVisibility()
           
static Ruby getDefaultInstance()
           
static Ruby getDefaultInstance(java.lang.Class regexpAdapterClass)
          Deprecated. use getDefaultInstance(String) or getDefaultInstance() instead.
static Ruby getDefaultInstance(java.lang.String regexpEngineName)
          Returns a default instance of the JRuby runtime.
 java.util.List getDynamicNames()
           
 DynamicVariableSet getDynamicVars()
          Getter for property dynamicVars.
 IRubyErrorHandler getErrorHandler()
          Returns the errorHandler.
 java.io.PrintStream getErrorStream()
           
 RubyExceptions getExceptions()
          Gets the exceptions
 IObjectFactory getFactory()
          Returns the factory.
 RubyBoolean getFalse()
          Returns the "false" instance from the instance pool.
 FrameStack getFrameStack()
           
 IGlobalVariables getGlobalVariables()
           
 java.io.InputStream getInputStream()
           
 IStack getIterStack()
           
 JavaSupport getJavaSupport()
           
 LastCallStatus getLastCallStatus()
          Returns the lastCallStatus.
 IRubyObject getLastline()
           
 ILoadService getLoadService()
          Returns the loadService.
 RubyModule getModule(java.lang.String name)
           
 IRubyObject getNil()
          Returns the "nil" singleton instance.
 RubyModule getOrCreateModule(java.lang.String name)
          In the current context, get the named module.
 java.io.PrintStream getOutputStream()
           
 Parser getParser()
           
 ISourcePosition getPosition()
           
 java.lang.Class getRegexpAdapterClass()
           
 RubyModule getRubyClass()
           
 RubyModule getRubyModule(java.lang.String name)
          Deprecated. use getModule(String) instead
 int getSafeLevel()
          Getter for property securityLevel.
 ScopeStack getScope()
          Getter for property rubyScope.
 java.lang.String getSourceFile()
          Getter for property sourceFile.
 int getSourceLine()
          Getter for property sourceLine.
 ThreadService getThreadService()
           
 IRubyObject getTopConstant(java.lang.String name)
           
 IRubyObject getTopSelf()
          Getter for property rubyTopSelf.
 RubyProc getTraceFunction()
           
 RubyBoolean getTrue()
          Returns the "true" instance from the instance pool.
 RubyModule getWrapper()
          Getter for property wrapper.
 boolean isBlockGiven()
           
 boolean isClassDefined(java.lang.String name)
           
 boolean isFBlockGiven()
           
 boolean isVerbose()
          Getter for property isVerbose.
 IRubyObject iterate(Callback iterateMethod, IRubyObject data1, Callback blockMethod, IRubyObject data2)
          rb_iterate
 void loadFile(java.io.File file, boolean wrap)
          Loads, compiles and interprets a Ruby file.
 void loadNode(java.lang.String scriptName, INode node, boolean wrap)
           
 void loadScript(RubyString scriptName, RubyString source, boolean wrap)
          This method compiles and interprets a Ruby script.
 void loadScript(java.lang.String scriptName, java.io.Reader source, boolean wrap)
           
 INode parse(java.io.Reader content, java.lang.String file)
           
 INode parse(java.lang.String content, java.lang.String file)
           
 void printError(RubyException excp)
          Prints an error with backtrace to the error stream.
 void secure(int level)
           
 void setCurrentVisibility(Visibility visibility)
           
 void setLastline(IRubyObject value)
           
 void setPosition(ISourcePosition position)
           
 void setPosition(java.lang.String file, int line)
           
 void setSafeLevel(int safeLevel)
          Setter for property securityLevel.
 void setTraceFunction(RubyProc traceFunction)
           
 void setVerbose(boolean verbose)
          Setter for property isVerbose.
 IRubyObject yield(IRubyObject value)
           
 IRubyObject yield(IRubyObject value, IRubyObject self, RubyModule klass, boolean checkArguments)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stackTraces

public int stackTraces

objectSpace

public ObjectSpace objectSpace

fixnumCache

public final RubyFixnum[] fixnumCache

symbolTable

public final RubySymbol.SymbolTable symbolTable

randomSeed

public long randomSeed

random

public java.util.Random random
Method Detail

getDefaultInstance

public static Ruby getDefaultInstance(java.lang.String regexpEngineName)
Returns a default instance of the JRuby runtime.

Parameters:
regexpEngineName - The regexp engine you want to use.
Returns:
the JRuby runtime

getDefaultInstance

public static Ruby getDefaultInstance()

getDefaultInstance

public static Ruby getDefaultInstance(java.lang.Class regexpAdapterClass)
Deprecated. use getDefaultInstance(String) or getDefaultInstance() instead.


evalScript

public java.lang.Object evalScript(java.lang.String script,
                                   java.lang.Class returnClass)
Deprecated. If anyone actually uses this method then speak up now!

Evaluates a script and returns an instance of class returnClass.

Parameters:
script - The script to evaluate
returnClass - The class which should be returned
Returns:
the result Object

evalScript

public IRubyObject evalScript(java.lang.String script)
Evaluates a script and returns a RubyObject.


eval

public IRubyObject eval(INode node)

getRegexpAdapterClass

public java.lang.Class getRegexpAdapterClass()

getClasses

public RubyClasses getClasses()

getTrue

public RubyBoolean getTrue()
Returns the "true" instance from the instance pool.

Returns:
The "true" instance.

getFalse

public RubyBoolean getFalse()
Returns the "false" instance from the instance pool.

Returns:
The "false" instance.

getNil

public IRubyObject getNil()
Returns the "nil" singleton instance.

Returns:
"nil"

getModule

public RubyModule getModule(java.lang.String name)

getRubyModule

public RubyModule getRubyModule(java.lang.String name)
Deprecated. use getModule(String) instead


getClass

public RubyClass getClass(java.lang.String name)
Returns a class from the instance pool.

Parameters:
name - The name of the class.
Returns:
The class.

defineClass

public RubyClass defineClass(java.lang.String name,
                             RubyClass superClass)
Define a new class with name 'name' and super class 'superClass'. MRI: rb_define_class / rb_define_class_id


defineClassUnder

public RubyClass defineClassUnder(java.lang.String name,
                                  RubyClass superClass,
                                  RubyModule parentClass)

defineModule

public RubyModule defineModule(java.lang.String name)
rb_define_module / rb_define_module_id


defineModuleUnder

public RubyModule defineModuleUnder(java.lang.String name,
                                    RubyModule parentModule)

getOrCreateModule

public RubyModule getOrCreateModule(java.lang.String name)
In the current context, get the named module. If it doesn't exist a new module is created.


getSafeLevel

public int getSafeLevel()
Getter for property securityLevel.

Returns:
Value of property securityLevel.

setSafeLevel

public void setSafeLevel(int safeLevel)
Setter for property securityLevel.

Parameters:
safeLevel - New value of property securityLevel.

secure

public void secure(int level)

defineGlobalConstant

public void defineGlobalConstant(java.lang.String name,
                                 IRubyObject value)
rb_define_global_const


getTopConstant

public IRubyObject getTopConstant(java.lang.String name)

isClassDefined

public boolean isClassDefined(java.lang.String name)

yield

public IRubyObject yield(IRubyObject value)

yield

public IRubyObject yield(IRubyObject value,
                         IRubyObject self,
                         RubyModule klass,
                         boolean checkArguments)

getTopSelf

public IRubyObject getTopSelf()
Getter for property rubyTopSelf.

Returns:
Value of property rubyTopSelf.

iterate

public IRubyObject iterate(Callback iterateMethod,
                           IRubyObject data1,
                           Callback blockMethod,
                           IRubyObject data2)
rb_iterate


getScope

public ScopeStack getScope()
Getter for property rubyScope.

Returns:
Value of property rubyScope.

getSourceFile

public java.lang.String getSourceFile()
Getter for property sourceFile.

Returns:
Value of property sourceFile.

getSourceLine

public int getSourceLine()
Getter for property sourceLine.

Returns:
Value of property sourceLine.

isVerbose

public boolean isVerbose()
Getter for property isVerbose.

Returns:
Value of property isVerbose.

isBlockGiven

public boolean isBlockGiven()

isFBlockGiven

public boolean isFBlockGiven()

setVerbose

public void setVerbose(boolean verbose)
Setter for property isVerbose.

Parameters:
verbose - New value of property isVerbose.

getDynamicVars

public DynamicVariableSet getDynamicVars()
Getter for property dynamicVars.

Returns:
Value of property dynamicVars.

getRubyClass

public RubyModule getRubyClass()

getFrameStack

public FrameStack getFrameStack()

getCurrentFrame

public Frame getCurrentFrame()

getJavaSupport

public JavaSupport getJavaSupport()

getIterStack

public IStack getIterStack()

getBlockStack

public BlockStack getBlockStack()

getCurrentVisibility

public Visibility getCurrentVisibility()

setCurrentVisibility

public void setCurrentVisibility(Visibility visibility)

getWrapper

public RubyModule getWrapper()
Getter for property wrapper.

Returns:
Value of property wrapper.

getExceptions

public RubyExceptions getExceptions()
Gets the exceptions

Returns:
Returns a RubyExceptions

defineVariable

public void defineVariable(GlobalVariable variable)
Defines a global variable


defineReadonlyVariable

public void defineReadonlyVariable(java.lang.String name,
                                   IRubyObject value)
defines a readonly global variable


parse

public INode parse(java.io.Reader content,
                   java.lang.String file)

parse

public INode parse(java.lang.String content,
                   java.lang.String file)

getLastline

public IRubyObject getLastline()

setLastline

public void setLastline(IRubyObject value)

getBackref

public IRubyObject getBackref()

getParser

public Parser getParser()

getThreadService

public ThreadService getThreadService()

getCurrentContext

public ThreadContext getCurrentContext()

getPosition

public ISourcePosition getPosition()

setPosition

public void setPosition(java.lang.String file,
                        int line)

setPosition

public void setPosition(ISourcePosition position)

getDynamicNames

public java.util.List getDynamicNames()

getFactory

public IObjectFactory getFactory()
Returns the factory.

Returns:
IObjectFactory

getLastCallStatus

public LastCallStatus getLastCallStatus()
Returns the lastCallStatus.

Returns:
LastCallStatus

getLoadService

public ILoadService getLoadService()
Returns the loadService.

Returns:
ILoadService

getErrorHandler

public IRubyErrorHandler getErrorHandler()
Returns the errorHandler.

Returns:
IRubyErrorHandler

getErrorStream

public java.io.PrintStream getErrorStream()

getInputStream

public java.io.InputStream getInputStream()

getOutputStream

public java.io.PrintStream getOutputStream()

printError

public void printError(RubyException excp)
Prints an error with backtrace to the error stream. MRI: eval.c - error_print()


loadScript

public void loadScript(RubyString scriptName,
                       RubyString source,
                       boolean wrap)
This method compiles and interprets a Ruby script. It can be used if you want to use JRuby as a Macro language.


loadScript

public void loadScript(java.lang.String scriptName,
                       java.io.Reader source,
                       boolean wrap)

loadNode

public void loadNode(java.lang.String scriptName,
                     INode node,
                     boolean wrap)

loadFile

public void loadFile(java.io.File file,
                     boolean wrap)
Loads, compiles and interprets a Ruby file. Used by Kernel#require.


callTraceFunction

public void callTraceFunction(java.lang.String event,
                              ISourcePosition position,
                              IRubyObject self,
                              java.lang.String name,
                              IRubyObject type)
Call the trace function MRI: eval.c - call_trace_func


getTraceFunction

public RubyProc getTraceFunction()

setTraceFunction

public void setTraceFunction(RubyProc traceFunction)

getGlobalVariables

public IGlobalVariables getGlobalVariables()

callbackFactory

public CallbackFactory callbackFactory()


Copyright © 2002 Jan Arne Petersen. All Rights Reserved.