In the documentation below:
name
is aString
orSymbol
.index
is anInteger
.
Format: Ruby code
sends InteropLibrary message
foreign_object[key]
sendsreadHashValue(foreign_object, key)
ifhasHashEntries(foreign_object)
foreign_object[name]
sendsreadMember(foreign_object, name)
foreign_object[index]
sendsreadArrayElement(foreign_object, index)
foreign_object[key] = value
sendswriteHashEntry(foreign_object, key)
ifhasHashEntries(foreign_object)
foreign_object[name] = value
sendswriteMember(foreign_object, name, value)
foreign_object[index] = value
sendswriteArrayElement(foreign_object, index, value)
foreign_object.name = value
sendswriteMember(foreign_object, name, value)
foreign_object.name = *arguments
sendswriteMember(foreign_object, name, arguments)
foreign_object.delete(key)
sendsremoveHashEntry(foreign_object, key)
ifhasHashEntries(foreign_object)
foreign_object.delete(name)
sendsremoveMember(foreign_object, name)
foreign_object.delete(index)
sendsremoveArrayElement(foreign_object, index)
foreign_object.call(*arguments)
sendsexecute(foreign_object, *arguments)
foreign_object.nil?
sendsisNull(foreign_object)
foreign_object.size
sendsgetArraySize(foreign_object)
foreign_object.instance_variables
sendsgetMembers(foreign_object)
and returns readable non-invocable membersforeign_object.methods
sendsgetMembers(foreign_object)
and returns invocable members merged with available Ruby methodsforeign_object.method_name
sendsinvokeMember(foreign_object, method_name)
if member is invocableforeign_object.method_name
sendsreadMember(foreign_object, method_name)
if member is readable but not invocableforeign_object.method_name
sendsreadMember(foreign_object, method_name)
and raises if member is neither invocable nor readableforeign_object.method_name(*arguments)
sendsinvokeMember(foreign_object, method_name, *arguments)
foreign_object.method_name(*arguments, &block)
sendsinvokeMember(foreign_object, method_name, *arguments, block)
foreign_object.new(*arguments)
sendsinstantiate(foreign_object, *arguments)
foreign_object.inspect
returns a Ruby-style#inspect
string showing members, array elements, etcforeign_object.to_s
sendsasTruffleString(foreign_object)
whenisString(foreign_object)
is trueforeign_object.to_s
sendstoDisplayString(foreign_object)
otherwiseforeign_object.to_str
sendsasTruffleString(foreign_object)
whenisString(foreign_object)
is trueforeign_object.to_str
raisesNameError
otherwiseforeign_object.to_a
converts to a RubyArray
withTruffle::Interop.to_array(foreign_object)
foreign_object.to_ary
converts to a RubyArray
withTruffle::Interop.to_array(foreign_object)
foreign_object.to_f
tries to converts to a RubyFloat
usingasDouble()
and(double) asLong()
andasBigInteger().doubleValue()
or raisesNameError
foreign_object.to_i
tries to converts to a RubyInteger
usingasInt()
andasLong()
andasBigInteger()
or raisesNameError
foreign_object.equal?(other)
sendsisIdentical(foreign_object, other)
foreign_object.eql?(other)
sendsisIdentical(foreign_object, other)
foreign_object.object_id
sendsidentityHashCode(foreign_object)
whenhasIdentity()
is true (which might not be unique)foreign_object.object_id
usesSystem.identityHashCode()
otherwise (which might not be unique)foreign_object.__id__
sendsidentityHashCode(foreign_object)
whenhasIdentity()
is true (which might not be unique)foreign_object.__id__
usesSystem.identityHashCode()
otherwise (which might not be unique)foreign_object.hash
sendsidentityHashCode(foreign_object)
whenhasIdentity()
is true (which might not be unique)foreign_object.hash
usesSystem.identityHashCode()
otherwise (which might not be unique)foreign_object.map
and otherEnumerable
methods work for foreign arraysforeign_object.map
and otherEnumerable
methods work for foreign iterables (hasIterator()
)
Use .respond_to?
for calling InteropLibrary
predicates:
foreign_object.respond_to?(:to_str)
sendsisString(foreign_object)
foreign_object.respond_to?(:to_a)
sendshasArrayElements(foreign_object)
foreign_object.respond_to?(:to_ary)
sendshasArrayElements(foreign_object)
foreign_object.respond_to?(:to_f)
sendsfitsInDouble()
foreign_object.respond_to?(:to_i)
sendsfitsInBigInteger()
foreign_object.respond_to?(:size)
sendshasArrayElements(foreign_object)
foreign_object.respond_to?(:call)
sendsisExecutable(foreign_object)
foreign_object.respond_to?(:new)
sendsisInstantiable(foreign_object)