public class InstanceVariable
extends java.lang.Object
BiVariable.Type
Modifier and Type | Field and Description |
---|---|
protected boolean |
fromRuby |
protected IRubyObject |
irubyObject |
protected java.lang.Object |
javaObject |
protected java.lang.Class |
javaType |
protected java.lang.String |
name |
protected IRubyObject |
receiver |
Constructor and Description |
---|
InstanceVariable(IRubyObject receiver,
java.lang.String name,
IRubyObject irubyObject)
A constructor used when instance variables are retrieved from Ruby.
|
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.
|
java.lang.Object |
getJavaObject()
Returns a value of the variable this object holds in Java type.
|
java.lang.String |
getName()
Returns a name of the variable this object holds.
|
IRubyObject |
getReceiver()
Returns the original receiver where this variable has been retrieved.
|
protected static RubyModule |
getRubyClass(Ruby runtime) |
IRubyObject |
getRubyObject()
Returns a value of the variable this object holds in
a org.jruby.runtime.builtin.IRubyObject type.
|
BiVariable.Type |
getType()
Returns enum type of this variable defined in
BiVariable . |
void |
inject()
Injects an instance variable value to a parsed Ruby script.
|
boolean |
isReceiverIdentical(RubyObject receiver)
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 instance variable.
|
protected static boolean |
isValidName(java.lang.String pattern,
java.lang.Object name) |
void |
remove()
Attempts to remove this variable from top self or receiver.
|
static void |
retrieve(RubyObject receiver,
BiVariableMap vars)
Retrieves instance variables from Ruby after the evaluation.
|
static void |
retrieveByKey(RubyObject receiver,
BiVariableMap vars,
java.lang.String key)
Retrieves a instance variable by key from Ruby runtime after the evaluation.
|
void |
setJavaObject(Ruby runtime,
java.lang.Object javaObject)
Sets a Java object as a value of this object.
|
void |
setRubyObject(IRubyObject rubyObject)
Sets a org.jruby.runtime.builtin.IRubyObject type, Ruby object as a value
of this object.
|
protected void |
updateByJavaObject(Ruby runtime,
java.lang.Object... values) |
protected void |
updateRubyObject(IRubyObject rubyObject) |
protected final IRubyObject receiver
protected final java.lang.String name
protected java.lang.Object javaObject
protected java.lang.Class javaType
protected IRubyObject irubyObject
protected boolean fromRuby
public InstanceVariable(IRubyObject receiver, java.lang.String name, IRubyObject irubyObject)
receiver
- a receiver object that this variable/constant is originally in. When
the variable/constant is originated from Ruby, receiver may not be null.name
- the instance variable nameirubyObject
- Ruby instance 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(RubyObject receiver, BiVariableMap vars)
runtime
- Ruby runtimereceiver
- receiver object returned when a script is evaluated.vars
- map to save retrieved instance variables.public static void retrieveByKey(RubyObject receiver, BiVariableMap vars, java.lang.String key)
receiver
- receiver object returned when a script is evaluated.vars
- map to save retrieved instance variables.key
- instace varible namepublic BiVariable.Type getType()
BiVariable
.public static boolean isValidName(java.lang.Object name)
name
- is a name to be checked.public void inject()
runtime
- is environment where a variable injection occursreceiver
- is the instance that will have variable injection.public void remove()
protected void updateByJavaObject(Ruby runtime, java.lang.Object... values)
protected void updateRubyObject(IRubyObject rubyObject)
public IRubyObject getReceiver()
BiVariable
getReceiver
in interface BiVariable
public boolean isReceiverIdentical(RubyObject receiver)
isReceiverIdentical
in interface BiVariable
public java.lang.String getName()
BiVariable
getName
in interface BiVariable
public java.lang.Object getJavaObject()
BiVariable
getJavaObject
in interface BiVariable
public void setJavaObject(Ruby runtime, java.lang.Object javaObject)
BiVariable
setJavaObject
in interface BiVariable
runtime
- is used to convert a Java object to Ruby object.javaObject
- is a variable value to be set.public IRubyObject getRubyObject()
BiVariable
getRubyObject
in interface BiVariable
public void setRubyObject(IRubyObject rubyObject)
BiVariable
setRubyObject
in interface BiVariable
rubyObject
- is a variable value to be set.protected static RubyModule getRubyClass(Ruby runtime)
protected static boolean isValidName(java.lang.String pattern, java.lang.Object name)
Copyright © 2001-2018 JRuby. All Rights Reserved.