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

public Class InstanceVariable

extends AbstractVariable
Class Inheritance
Imports
org.jruby.embed.internal.BiVariableMap, java.util.List, org.jruby.RubyObject, org.jruby.runtime.builtin.IRubyObject, .InstanceVariables, org.jruby.runtime.ivars.VariableAccessor

An implementation of BiVariable for a Ruby instance variable.
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
InstanceVariable(RubyObject receiver, String name, Object... javaObjects)

public
InstanceVariable(IRubyObject
a receiver object that this variable/constant is originally in. When the variable/constant is originated from Ruby, receiver may not be null.
receiver
,
String
the instance variable name
name
,
IRubyObject
Ruby instance object
irubyObject
)

A constructor used when instance variables are retrieved from Ruby.

pack-priv
InstanceVariable(RubyObject receiver, String name, IRubyObject irubyObject)

Method Summary

Modifier and TypeMethod and Description
public static BiVariable

Returns:

the instance of InstanceVariable
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.InstanceVariable.
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 an instance variable value to a parsed Ruby script.

public static boolean

Returns:

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

Returns true if the given name is a decent Ruby instance 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 instance variables.
vars
)

Retrieves instance variables from Ruby after the evaluation.

public static void
retrieveByKey(RubyObject
receiver object returned when a script is evaluated.
receiver
,
BiVariableMap
map to save retrieved instance variables.
vars
,
String
instace varible name
key
)

Retrieves a instance variable by key from Ruby runtime after the evaluation.

pack-priv static void
updateInstanceVar(final RubyObject receiver, final BiVariableMap vars)

private static void
Inherited from org.jruby.embed.variable.AbstractVariable:
getCurrentContextgetJavaObjectgetNamegetReceivergetRubyClassgetRubyObjectgetRuntimegetTopSelfgetTopSelfisReceiverIdenticalisValidNamesetJavaObjectsetRubyObjectupdateByJavaObjectupdateRubyObject

Field Detail

VALID_NAMEback to summary
private static final String VALID_NAME

Constructor Detail

InstanceVariableback to summary
private InstanceVariable(RubyObject receiver, String name, Object... javaObjects)
InstanceVariableback to summary
public InstanceVariable(IRubyObject receiver, String name, IRubyObject irubyObject)

A constructor used when instance variables are retrieved from Ruby.

Parameters
receiver:IRubyObject

a receiver object that this variable/constant is originally in. When the variable/constant is originated from Ruby, receiver may not be null.

name:String

the instance variable name

irubyObject:IRubyObject

Ruby instance object

InstanceVariableback to summary
pack-priv InstanceVariable(RubyObject receiver, String name, IRubyObject irubyObject)

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 an instance 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 InstanceVariable

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.InstanceVariable.

Annotations
@Override
injectback to summary
public void inject()

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

Injects an instance 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 instance variable. Unless returns false.

Parameters
name:Object

is a name to be checked.

Returns:boolean

true if the given name is of a Ruby instance 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 instance variables from Ruby after the evaluation.

Parameters
receiver:RubyObject

receiver object returned when a script is evaluated.

vars:BiVariableMap

map to save retrieved instance variables.

retrieveByKeyback to summary
public static void retrieveByKey(RubyObject receiver, BiVariableMap vars, String key)

Retrieves a instance variable by key from Ruby runtime after the evaluation. This method is used when eager retrieval is off.

Parameters
receiver:RubyObject

receiver object returned when a script is evaluated.

vars:BiVariableMap

map to save retrieved instance variables.

key:String

instace varible name

updateInstanceVarback to summary
pack-priv static void updateInstanceVar(final RubyObject receiver, final BiVariableMap vars)
updateVariableback to summary
private static void updateVariable(RubyObject receiver, BiVariableMap vars, String key, IRubyObject value)