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

public Class Constant

extends AbstractVariable
Class Inheritance
Imports
java.util.Collection, .Map, org.jruby.Ruby, .RubyClass, .RubyModule, .RubyObject, org.jruby.embed.internal.BiVariableMap, org.jruby.javasupport.JavaUtil, org.jruby.runtime.ThreadContext, org.jruby.runtime.builtin.IRubyObject

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

pack-priv
Constant(RubyObject
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 constant name
name
,
IRubyObject
Ruby constant object
irubyObject
)

A constructor used when constants are retrieved from Ruby.

Method Summary

Modifier and TypeMethod and Description
public static BiVariable

Returns:

the instance of Constant
getInstance
(RubyObject
object that this constant/variable is in.
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.Constant.
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 constant value to a parsed Ruby script.

public static boolean

Returns:

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

Returns true if the given name is a decent Ruby constant.

public void
remove()

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

Attempts to remove this constant from top self or receiver.

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

Retrieves constants from Ruby after the evaluation or method invocation.

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

Retrieves a constant by key from Ruby runtime after the evaluation.

private static void
updateConstants(ThreadContext context, 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

Constantback to summary
private Constant(RubyObject receiver, String name, Object... javaObjects)
Constantback to summary
pack-priv Constant(RubyObject receiver, String name, IRubyObject irubyObject)

A constructor used when constants are retrieved from Ruby.

Parameters
receiver:RubyObject

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 constant name

irubyObject:IRubyObject

Ruby constant 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 constant is put in BiVariableMap.

Parameters
receiver:RubyObject

object that this constant/variable is in.

name:String

a variable name

javaObject:Object[]

Java object that should be assigned to.

Returns:BiVariable

the instance of Constant

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

Annotations
@Override
injectback to summary
public void inject()

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

Injects a constant 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 constant. Unless returns false.

Parameters
name:Object

is a name to be checked.

Returns:boolean

true if the given name is of a Ruby constant.

removeback to summary
public void remove()

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

Attempts to remove this constant from top self or receiver.

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

Retrieves constants from Ruby after the evaluation or method invocation.

Parameters
receiver:RubyObject

receiver object returned when a script is evaluated.

vars:BiVariableMap

map to save retrieved constants.

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

Retrieves a constant 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

updateConstantsback to summary
private static void updateConstants(ThreadContext context, final RubyObject receiver, final BiVariableMap vars)
updateConstantsOfSuperClassback to summary
private static void updateConstantsOfSuperClass(RubyObject receiver, BiVariableMap vars)