Top Description Fields Methods
org.jruby.runtime.builtin

public Interface IRubyObject

Known Direct Subinterfaces
org.jruby.javasupport.proxy.JavaProxyMethod
Known Direct Implementers
org.jruby.RubyBasicObject, org.jruby.ir.operands.UndefinedValue
Imports
java.util.List, org.jruby.Ruby, .RubyArray, .RubyClass, .RubyFloat, .RubyHash, .RubyInteger, .RubyString, org.jruby.api.JRubyAPI, org.jruby.runtime.Block, .JavaSites, .ThreadContext, org.jruby.runtime.marshal.MarshalDumper, org.jruby.util.io.RubyOutputStream

Object is the parent class of all classes in Ruby. Its methods are therefore available to all objects unless explicitly overridden.

Field Summary

Modifier and TypeField and Description
public static final IRubyObject[]

Method Summary

Modifier and TypeMethod and Description
public void
addFinalizer(IRubyObject finalizer)
Deprecated

public default IRubyObject
public IRubyObject

Returns:

a string value
anyToString
()

make this object into a string (hopefully)

public static IRubyObject[]
array(int length)

public String

Returns:

String the symbol name
asJavaString
()

Convert the object into a symbol name if possible.

public RubyString

Returns:

string representation
asString
()

rb_obj_as_string

public IRubyObject
public IRubyObject
public IRubyObject
callMethod(ThreadContext context, String name, IRubyObject[] args)

public IRubyObject
callMethod(ThreadContext context, String name, IRubyObject[] args, Block block)

public IRubyObject
callMethod(ThreadContext context, int methodIndex, String name)
Deprecated

public IRubyObject
callMethod(ThreadContext context, int methodIndex, String name, IRubyObject arg)
Deprecated

public IRubyObject
callSuper(ThreadContext context, IRubyObject[] args, Block block)
Deprecated

public IRubyObject

Returns:

nil if type check failed
checkArrayType
()

is this an array if so return it otherwise nil

public IRubyObject
public IRubyObject
public IRubyObject

Returns:

nil if type check failed
checkStringType
()

is this a string if so return it otherwise nil

public default IRubyObject

Returns:

the string if so
checkStringType19
()
Deprecated Use checkStringType() instead.

is this a string?

public RubyArray<T extends IRubyObject>

Returns:

an array value
convertToArray
()

Converts this Ruby object to an Array.

public RubyFloat

Returns:

a float value
convertToFloat
()

Converts this Ruby object to a Float (using to_f).

public RubyHash

Returns:

a hash value
convertToHash
()

Converts this Ruby object to a Hash.

public RubyInteger

Returns:

an integer value
convertToInteger
()

Converts this Ruby object to an Integer.

public RubyInteger

Returns:

an integer value
convertToInteger
(String
method to use e.g. to_i
convertMethod
)

Converts this Ruby object to an Integer.

public default RubyInteger

Returns:

integer
convertToInteger
(int
index
convertMethodIndex
,
String
conversion method name
convertMethod
)
Deprecated

convert this object to an integer

public RubyString

Returns:

a string value
convertToString
()

Converts this Ruby object to a String.

public void
public Object

Returns:

the object wrapped.
dataGetStruct
()

Our version of Data_Get_Struct.

public Object
dataGetStructChecked()
Deprecated

public void
dataWrapStruct(Object
the object to wrap
obj
)

Our version of Data_Wrap_Struct.

public IRubyObject

Returns:

a dup-ed object
dup
()

RubyMethod dup.

public default IRubyObject

Returns:

a dup-ed object
dup
(ThreadContext
the thread context
context
)

RubyMethod dup.

public boolean
public InstanceVariables
public InternalVariables
public Class<T>

Returns:

Class
getJavaClass
()

RubyMethod getJavaClass.

public default List<Variable<Object>>

Returns:

a mutable list of all marshalable variables (ivar/internal)
getMarshalVariableList
()

all marshable values

public RubyClass

Returns:

the Ruby (meta) class
getMetaClass
()

Retrieve self.class.

public Ruby

Returns:

the Ruby runtime this belongs to
getRuntime
()

RubyMethod getRuntime.

public RubyClass

Returns:

the Ruby singleton class
getSingletonClass
()

Retrieve self.singleton_class.

public RubyClass

Returns:

RubyClass
getType
()

RubyMethod getType.

public Object
getVariable(int index)

public int

Returns:

the count of all variables (ivar/cvar/constant/internal)
getVariableCount
()

how many variables?

public List<Variable<Object>>

Returns:

a list of all variables (ivar/internal)
getVariableList
()

list of all variables

public List<String>

Returns:

a list of all variable names (ivar/cvar/constant/internal)
getVariableNameList
()

list of all variable names

public boolean

Returns:

true if object has any variables, else false
hasVariables
()

Returns true if object has any variables, defined as:

  • instance variables
  • class variables
  • constants
  • internal variables, such as those used when marshalling Ranges and Exceptions
public IRubyObject

Returns:

the object id
id
()

The id of the object

public IRubyObject
infectBy(IRubyObject obj)
Deprecated

public IRubyObject

Returns:

String
inspect
()

RubyMethod inspect.

public default IRubyObject
public boolean

Returns:

true if an object is Ruby Class instance (note that it will return false for Ruby singleton classes).
isClass
()

If is_a?

public boolean

Returns:

boolean
isFrozen
()

RubyMethod isFrozen.

public boolean

Returns:

boolean
isImmediate
()

Is this an immediate object

public boolean

Returns:

true if an object is Ruby Module instance (note that it will return false for Ruby Classes).
isModule
()

If is_a?

public boolean

Returns:

true for nil only
isNil
()

Check whether this object is nil.

public boolean

Returns:

boolean
isSpecialConst
()

Is this a special constant

public boolean
isTaint()
Deprecated

public boolean

Returns:

false for nil and false, true otherwise
isTrue
()

Check whether this object is truthy.

public boolean

Returns:

boolean
isUntrusted
()

RubyMethod isUntrusted.

public default void
public IRubyObject
public IRubyObject
public IRubyObject

Returns:

a cloned object
rbClone
()

RubyMethod clone.

public void
public boolean

Returns:

boolean
respondsTo
(String
method name
string
)

RubyMethod respondsTo.

public boolean

Returns:

boolean
respondsToMissing
(String
method name
string
)

RubyMethod respondsTo.

public boolean

Returns:

boolean
respondsToMissing
(String
method name
string
,
boolean
private?
priv
)

RubyMethod respondsTo.

public void
setFrozen(boolean
boolean
b
)

RubyMethod setFrozen.

public void
setTaint(boolean taint)
Deprecated

public void
setUntrusted(boolean
boolean
b
)

RubyMethod setUntrusted.

public void
setVariable(int index, Object value)

public default RubyClass
public void
syncVariables(List<Variable<Object>>
the variables to be set for object
variables
)
Deprecated

Sets object's variables to those in the supplied list, removing/replacing any previously defined variables.

public void
syncVariables(IRubyObject
the source object containing the variables to sync
source
)

Sets object's variables to those in the supplied object, removing/replacing any previously defined variables of the same name.

public <
type
T
>
T

Returns:

java type
toJava
(Class<T>
The target type to which the object should be converted.
type
)

Convert the object to the specified Java class, if possible.

Field Detail

NULL_ARRAYback to summary
public static final IRubyObject[] NULL_ARRAY

Method Detail

addFinalizerback to summary
public void addFinalizer(IRubyObject finalizer)

Deprecated

Annotations
@Deprecated
addFinalizerback to summary
public default IRubyObject addFinalizer(ThreadContext context, IRubyObject finalizer)
Annotations
@SuppressWarnings:deprecation
anyToStringback to summary
public IRubyObject anyToString()

make this object into a string (hopefully)

Returns:IRubyObject

a string value

arrayback to summary
public static IRubyObject[] array(int length)
asJavaStringback to summary
public String asJavaString()

Convert the object into a symbol name if possible.

Returns:String

String the symbol name

asStringback to summary
public RubyString asString()

rb_obj_as_string

Returns:RubyString

string representation

callMethodback to summary
public IRubyObject callMethod(ThreadContext context, String name)
callMethodback to summary
public IRubyObject callMethod(ThreadContext context, String name, IRubyObject arg)
callMethodback to summary
public IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args)
callMethodback to summary
public IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args, Block block)
callMethodback to summary
public IRubyObject callMethod(ThreadContext context, int methodIndex, String name)

Deprecated

Annotations
@Deprecated
callMethodback to summary
public IRubyObject callMethod(ThreadContext context, int methodIndex, String name, IRubyObject arg)

Deprecated

Annotations
@Deprecated
callSuperback to summary
public IRubyObject callSuper(ThreadContext context, IRubyObject[] args, Block block)

Deprecated

Annotations
@Deprecated
checkArrayTypeback to summary
public IRubyObject checkArrayType()

is this an array if so return it otherwise nil

Returns:IRubyObject

nil if type check failed

checkCallMethodback to summary
public IRubyObject checkCallMethod(ThreadContext context, String name)
checkCallMethodback to summary
public IRubyObject checkCallMethod(ThreadContext context, JavaSites.CheckedSites sites)
checkStringTypeback to summary
public IRubyObject checkStringType()

is this a string if so return it otherwise nil

Returns:IRubyObject

nil if type check failed

checkStringType19back to summary
public default IRubyObject checkStringType19()

Deprecated

Use checkStringType() instead.

is this a string?

Returns:IRubyObject

the string if so

Annotations
@Deprecated
convertToArrayback to summary
public RubyArray<T extends IRubyObject> convertToArray()

Converts this Ruby object to an Array.

Returns:RubyArray<T extends IRubyObject>

an array value

convertToFloatback to summary
public RubyFloat convertToFloat()

Converts this Ruby object to a Float (using to_f).

Returns:RubyFloat

a float value

convertToHashback to summary
public RubyHash convertToHash()

Converts this Ruby object to a Hash.

Returns:RubyHash

a hash value

convertToIntegerback to summary
public RubyInteger convertToInteger()

Converts this Ruby object to an Integer. Uses the default conversion method (to_int).

Returns:RubyInteger

an integer value

convertToIntegerback to summary
public RubyInteger convertToInteger(String convertMethod)

Converts this Ruby object to an Integer.

Parameters
convertMethod:String

method to use e.g. to_i

Returns:RubyInteger

an integer value

convertToIntegerback to summary
public default RubyInteger convertToInteger(int convertMethodIndex, String convertMethod)

Deprecated

convert this object to an integer

Parameters
convertMethodIndex:int

index

convertMethod:String

conversion method name

Returns:RubyInteger

integer

Annotations
@Deprecated
See Also
convertToInteger(String)
convertToStringback to summary
public RubyString convertToString()

Converts this Ruby object to a String.

Returns:RubyString

a string value

copySpecialInstanceVariablesback to summary
public void copySpecialInstanceVariables(IRubyObject clone)
dataGetStructback to summary
public Object dataGetStruct()

Our version of Data_Get_Struct. Returns a wrapped data value if there is one, otherwise returns null.

Returns:Object

the object wrapped.

dataGetStructCheckedback to summary
public Object dataGetStructChecked()

Deprecated

Annotations
@Deprecated
dataWrapStructback to summary
public void dataWrapStruct(Object obj)

Our version of Data_Wrap_Struct. This method will just set a private pointer to the object provided. This pointer is transient and will not be accessible from Ruby.

Parameters
obj:Object

the object to wrap

dupback to summary
public IRubyObject dup()

RubyMethod dup.

Returns:IRubyObject

a dup-ed object

dupback to summary
public default IRubyObject dup(ThreadContext context)

RubyMethod dup.

Parameters
context:ThreadContext

the thread context

Returns:IRubyObject

a dup-ed object

Since
10.0
eqlback to summary
public boolean eql(IRubyObject other)
getInstanceVariablesback to summary
public InstanceVariables getInstanceVariables()
getInternalVariablesback to summary
public InternalVariables getInternalVariables()
getJavaClassback to summary
public Class<T> getJavaClass()

RubyMethod getJavaClass.

Returns:Class<T>

Class

getMarshalVariableListback to summary
public default List<Variable<Object>> getMarshalVariableList()

all marshable values

Returns:List<Variable<Object>>

a mutable list of all marshalable variables (ivar/internal)

getMetaClassback to summary
public RubyClass getMetaClass()

Retrieve self.class.

Returns:RubyClass

the Ruby (meta) class

Annotations
@JRubyAPI
getRuntimeback to summary
public Ruby getRuntime()

RubyMethod getRuntime.

Returns:Ruby

the Ruby runtime this belongs to

getSingletonClassback to summary
public RubyClass getSingletonClass()

Retrieve self.singleton_class.

Returns:RubyClass

the Ruby singleton class

getTypeback to summary
public RubyClass getType()

RubyMethod getType.

Returns:RubyClass

RubyClass

getVariableback to summary
public Object getVariable(int index)
getVariableCountback to summary
public int getVariableCount()

how many variables?

Returns:int

the count of all variables (ivar/cvar/constant/internal)

getVariableListback to summary
public List<Variable<Object>> getVariableList()

list of all variables

Returns:List<Variable<Object>>

a list of all variables (ivar/internal)

getVariableNameListback to summary
public List<String> getVariableNameList()

list of all variable names

Returns:List<String>

a list of all variable names (ivar/cvar/constant/internal)

hasVariablesback to summary
public boolean hasVariables()

Returns true if object has any variables, defined as:

  • instance variables
  • class variables
  • constants
  • internal variables, such as those used when marshalling Ranges and Exceptions
Returns:boolean

true if object has any variables, else false

idback to summary
public IRubyObject id()

The id of the object

Returns:IRubyObject

the object id

infectByback to summary
public IRubyObject infectBy(IRubyObject obj)

Deprecated

Annotations
@Deprecated
inspectback to summary
public IRubyObject inspect()

RubyMethod inspect.

Returns:IRubyObject

String

inspectback to summary
public default IRubyObject inspect(ThreadContext context)
isClassback to summary
public boolean isClass()

If is_a? semantics is required, use (someObject instanceof RubyClass/MetaClass) instead.

Returns:boolean

true if an object is Ruby Class instance (note that it will return false for Ruby singleton classes).

isFrozenback to summary
public boolean isFrozen()

RubyMethod isFrozen.

Returns:boolean

boolean

isImmediateback to summary
public boolean isImmediate()

Is this an immediate object

Returns:boolean

boolean

isModuleback to summary
public boolean isModule()

If is_a? semantics is required, use (someObject instanceof RubyModule) instead.

Returns:boolean

true if an object is Ruby Module instance (note that it will return false for Ruby Classes).

isNilback to summary
public boolean isNil()

Check whether this object is nil. MRI: NIL_P macro

Returns:boolean

true for nil only

isSpecialConstback to summary
public boolean isSpecialConst()

Is this a special constant

Returns:boolean

boolean

isTaintback to summary
public boolean isTaint()

Deprecated

Annotations
@Deprecated
isTrueback to summary
public boolean isTrue()

Check whether this object is truthy.

Returns:boolean

false for nil and false, true otherwise

isUntrustedback to summary
public boolean isUntrusted()

RubyMethod isUntrusted.

Returns:boolean

boolean

marshalLiveVariablesback to summary
public default void marshalLiveVariables(MarshalDumper stream, ThreadContext context, RubyOutputStream out)
op_eqqback to summary
public IRubyObject op_eqq(ThreadContext context, IRubyObject other)
op_equalback to summary
public IRubyObject op_equal(ThreadContext context, IRubyObject other)
rbCloneback to summary
public IRubyObject rbClone()

RubyMethod clone.

Returns:IRubyObject

a cloned object

removeFinalizersback to summary
public void removeFinalizers()
respondsToback to summary
public boolean respondsTo(String string)

RubyMethod respondsTo.

Parameters
string:String

method name

Returns:boolean

boolean

respondsToMissingback to summary
public boolean respondsToMissing(String string)

RubyMethod respondsTo.

Parameters
string:String

method name

Returns:boolean

boolean

respondsToMissingback to summary
public boolean respondsToMissing(String string, boolean priv)

RubyMethod respondsTo.

Parameters
string:String

method name

priv:boolean

private?

Returns:boolean

boolean

setFrozenback to summary
public void setFrozen(boolean b)

RubyMethod setFrozen.

Parameters
b:boolean

boolean

setTaintback to summary
public void setTaint(boolean taint)

Deprecated

Annotations
@Deprecated
setUntrustedback to summary
public void setUntrusted(boolean b)

RubyMethod setUntrusted.

Parameters
b:boolean

boolean

setVariableback to summary
public void setVariable(int index, Object value)
singletonClassback to summary
public default RubyClass singletonClass(ThreadContext context)
Annotations
@JRubyAPI
syncVariablesback to summary
public void syncVariables(List<Variable<Object>> variables)

Deprecated

Sets object's variables to those in the supplied list, removing/replacing any previously defined variables. Applies to all variable types (ivar/cvar/constant/internal).

Parameters
variables:List<Variable<Object>>

the variables to be set for object

Annotations
@Deprecated
syncVariablesback to summary
public void syncVariables(IRubyObject source)

Sets object's variables to those in the supplied object, removing/replacing any previously defined variables of the same name. Applies to all variable types (ivar/cvar/constant/internal).

Parameters
source:IRubyObject

the source object containing the variables to sync

toJavaback to summary
public <T> T toJava(Class<T> type)

Convert the object to the specified Java class, if possible.

Parameters
<T>
type
type:Class<T>

The target type to which the object should be converted.

Returns:T

java type