Top Description Fields Constructors Methods
org.jruby.embed.variable

public Class PersistentLocalVariable

extends AbstractVariable
Class Inheritance
Imports
org.jruby.RubyObject, org.jruby.embed.internal.BiVariableMap, org.jruby.runtime.DynamicScope, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.scope.ManyVarsDynamicScope

An implementation of BiVariable for a persistent local variable. This type of a local variable survives over multiple evaluation.
Author
Yoko Harada <[email protected]>

Field Summary

Modifier and TypeField and Description
private static final String
Inherited from org.jruby.embed.variable.AbstractVariable:
fromRubyjavaObjectjavaTypenamereceiverrubyObject

Constructor Summary

AccessConstructor and Description
private
PersistentLocalVariable(RubyObject receiver, String name, Object... javaObjects)

pack-priv
PersistentLocalVariable(RubyObject origin, String
the persistent local variable name
name
,
IRubyObject
Ruby local object
irubyObject
)

A constructor used when persistent local variables are retrieved from Ruby.

Method Summary

Modifier and TypeMethod and Description
public static BiVariable

Returns:

the instance of PersistentLocalVariable
getInstance
(RubyObject
Receiver object returned when a script is evaluated.
receiver
,
String
a variable name
name
,
Object...
Java object that should be assigned to.
javaObject
)

Returns an instance of this class.

public BiVariable.Type

Returns:

this enum type, BiVariable.Type.LocalVariable.
getType
()

Implements org.jruby.embed.variable.BiVariable.getType.

Returns enum type of this variable defined in BiVariable.

public void
inject()

Implements org.jruby.embed.variable.BiVariable.inject.

Injects a local variable value to a parsed Ruby script.

public static boolean

Returns:

true if the given name is of a Ruby local variable.
isValidName
(Object
is a name to be checked.
name
)

Returns true if the given name is a decent Ruby local variable.

public void
remove()

Implements org.jruby.embed.variable.BiVariable.remove.

Attempts to remove this variable from top self or receiver.

public static void
retrieve(RubyObject
receiver object returned when a script is evaluated.
receiver
,
BiVariableMap
map to save retrieved local variables.
vars
)

Retrieves local variables from Ruby after the evaluation.

Inherited from org.jruby.embed.variable.AbstractVariable:
getCurrentContextgetJavaObjectgetNamegetReceivergetRubyClassgetRubyObjectgetRuntimegetTopSelfgetTopSelfisReceiverIdenticalisValidNamesetJavaObjectsetRubyObjectupdateByJavaObjectupdateRubyObject

Field Detail

VALID_NAMEback to summary
private static final String VALID_NAME

Constructor Detail

PersistentLocalVariableback to summary
private PersistentLocalVariable(RubyObject receiver, String name, Object... javaObjects)
PersistentLocalVariableback to summary
pack-priv PersistentLocalVariable(RubyObject origin, String name, IRubyObject irubyObject)

A constructor used when persistent local variables are retrieved from Ruby.

Parameters
name:String

the persistent local variable name

irubyObject:IRubyObject

Ruby local object

Method Detail

getInstanceback to summary
public static BiVariable getInstance(RubyObject receiver, String name, Object... javaObject)

Returns an instance of this class. This factory method is used when a persistent local variable is put in BiVariableMap.

Parameters
receiver:RubyObject

Receiver object returned when a script is evaluated.

name:String

a variable name

javaObject:Object[]

Java object that should be assigned to.

Returns:BiVariable

the instance of PersistentLocalVariable

getTypeback to summary
public BiVariable.Type getType()

Implements org.jruby.embed.variable.BiVariable.getType.

Returns enum type of this variable defined in BiVariable.

Returns:BiVariable.Type

this enum type, BiVariable.Type.LocalVariable.

Annotations
@Override
injectback to summary
public void inject()

Implements org.jruby.embed.variable.BiVariable.inject.

Injects a local variable value to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed.

Annotations
@Override
isValidNameback to summary
public static boolean isValidName(Object name)

Returns true if the given name is a decent Ruby local variable. Unless returns false.

Parameters
name:Object

is a name to be checked.

Returns:boolean

true if the given name is of a Ruby local variable.

removeback to summary
public void remove()

Implements org.jruby.embed.variable.BiVariable.remove.

Attempts to remove this variable from top self or receiver.

Annotations
@Override
retrieveback to summary
public static void retrieve(RubyObject receiver, BiVariableMap vars)

Retrieves local variables from Ruby after the evaluation. This retrieval doesn't depend on eager option. Local variables are always retrieved eagerly.

Parameters
receiver:RubyObject

receiver object returned when a script is evaluated.

vars:BiVariableMap

map to save retrieved local variables.