public class GlobalVariable extends AbstractVariable
BiVariable.Type| Modifier and Type | Field and Description |
|---|---|
private static java.util.Set<java.lang.String> |
PREDEFINED_NAMES |
private static java.lang.String[] |
PREDEFINED_PATTERNS |
private static java.lang.String |
VALID_NAME |
fromRuby, irubyObject, javaObject, javaType, name, receiver| Modifier | Constructor and Description |
|---|---|
(package private) |
GlobalVariable(RubyObject receiver,
java.lang.String name,
IRubyObject irubyObject)
A constructor used when global variables are retrieved from Ruby.
|
protected |
GlobalVariable(RubyObject receiver,
java.lang.String name,
java.lang.Object... javaObjects) |
| Modifier and Type | Method and Description |
|---|---|
static BiVariable |
getInstance(RubyObject receiver,
java.lang.String name,
java.lang.Object... javaObject)
Returns an instance of this class.
|
BiVariable.Type |
getType()
Returns enum type of this variable defined in
BiVariable. |
void |
inject()
A global variable is injected when it is set.
|
protected static boolean |
isPredefined(java.lang.String name) |
boolean |
isReceiverIdentical(RubyObject recv)
Returns true if a given receiver is identical to the receiver this object has.
|
static boolean |
isValidName(java.lang.Object name)
Returns true if the given name is a decent Ruby global variable.
|
void |
remove()
Attempts to remove this variable from top self or receiver.
|
static void |
retrieve(IRubyObject receiver,
BiVariableMap vars)
Retrieves global variables from Ruby after the evaluation.
|
static void |
retrieveByKey(Ruby runtime,
BiVariableMap vars,
java.lang.String key)
Retrieves a global variable by key from Ruby after the evaluation.
|
void |
setJavaObject(Ruby runtime,
java.lang.Object javaObject)
Sets a Java object and its Ruby type as a value of this object.
|
void |
tryEagerInjection(IRubyObject receiver)
Injects a global variable value to a parsed Ruby script.
|
void |
tryEagerInjection(Ruby runtime,
IRubyObject receiver)
Deprecated.
|
private static void |
updateGlobalVar(BiVariableMap vars,
RubyObject receiver,
java.lang.String name,
IRubyObject value) |
getCurrentContext, getJavaObject, getName, getReceiver, getRubyClass, getRubyObject, getRuntime, getTopSelf, getTopSelf, isValidName, setRubyObject, updateByJavaObject, updateRubyObjectprivate static final java.lang.String VALID_NAME
private static final java.lang.String[] PREDEFINED_PATTERNS
private static final java.util.Set<java.lang.String> PREDEFINED_NAMES
protected GlobalVariable(RubyObject receiver, java.lang.String name, java.lang.Object... javaObjects)
GlobalVariable(RubyObject receiver, java.lang.String name, IRubyObject irubyObject)
name - the global variable nameirubyObject - Ruby global objectpublic static BiVariable getInstance(RubyObject receiver, java.lang.String name, java.lang.Object... javaObject)
BiVariableMap.runtime - Ruby runtimename - a variable namejavaObject - Java object that should be assigned to.public static void retrieve(IRubyObject receiver, BiVariableMap vars)
runtime - Ruby runtimereceiver - receiver object returned when a script is evaluated.vars - map to save retrieved global variables.private static void updateGlobalVar(BiVariableMap vars, RubyObject receiver, java.lang.String name, IRubyObject value)
public static void retrieveByKey(Ruby runtime, BiVariableMap vars, java.lang.String key)
runtime - Ruby runtimereceiver - receiver object returned when a script is evaluated.vars - map to save a retrieved global variable.key - name of the global variableprotected static boolean isPredefined(java.lang.String name)
public BiVariable.Type getType()
BiVariable.public static boolean isValidName(java.lang.Object name)
name - is a name to be checked.public void setJavaObject(Ruby runtime, java.lang.Object javaObject)
setJavaObject in interface BiVariablesetJavaObject in class AbstractVariableruntime - is used to convert a Java object to Ruby object.javaObject - is a variable value to be set.public void inject()
@Deprecated public void tryEagerInjection(Ruby runtime, IRubyObject receiver)
public void tryEagerInjection(IRubyObject receiver)
runtime - is environment where a variable injection occursreceiver - is the instance that will have variable injection.public void remove()
public boolean isReceiverIdentical(RubyObject recv)
isReceiverIdentical in interface BiVariableisReceiverIdentical in class AbstractVariable