A list of currently supported classes and methods, based on the implementations in mrubyedge/src/yamrb/prelude/.
Legend
.method— class method (self.method)#method— instance method(alias: x)— also available under this name[feature: xxx]— requires the corresponding Cargo feature flag
This VM decodes the opcode table mruby 4.0 numbers, and rite::load refuses a chunk whose header says anything but 04 — mruby 3.x bytecode has to be recompiled. See docs/table.html for the per-opcode status.
The opcodes mruby 4.0 added over 3.x: GETIDX0, MATCHERR, SSEND0, SEND0, BLKCALL, RETSELF, RETNIL, RETTRUE, RETFALSE, ADDILV, SUBILV, TDEF, SDEF; ENTER reads the 24-bit flags, including &nil (a method refusing a block). LOADTRUE/LOADFALSE/LOADI8 are 3.x's LOADT/LOADF/LOADI renamed.
| Note | |
|---|---|
MATCHERR |
raises NoMatchingPatternError; the rest of pattern matching (deconstruct, deconstruct_keys) is not provided, so only value patterns in case/in run end to end |
| tests | the whole test suite compiles its Ruby with mruby-compiler2; tests/opcodes40.rs covers the added opcodes one snippet at a time and then a whole chunk |
prelude/object.rs
| Method | Notes |
|---|---|
#initialize |
|
#== |
|
#!= |
|
#=== |
|
#object_id |
alias: __id__ |
#to_s |
|
#inspect |
|
#raise |
|
#nil? |
|
#lambda |
alias: proc |
#is_a? |
alias: kind_of? |
#class |
|
#<=> |
|
#method_missing |
|
#extend |
|
#loop |
|
#block_given? |
|
#respond_to? |
|
#public_send |
|
#wasm? |
mruby/edge specific |
#puts |
[feature: wasi] only |
#p |
[feature: wasi] only |
#debug |
[feature: wasi] only |
| Constant | Value |
|---|---|
RUBY_VERSION |
VM VERSION string |
MRUBY_VERSION |
same as above |
MRUBY_EDGE_VERSION |
same as above |
RUBY_ENGINE |
VM ENGINE string |
prelude/exception.rs
Defined classes (with inheritance):
Exception
├── InternalError
├── NoMemoryError
├── ScriptError
│ └── LoadError
├── SyntaxError
├── SignalException
│ └── Interrupt
├── SystemExit
├── SystemStackError
└── StandardError
├── RuntimeError
├── TypeError
├── ArgumentError
├── RangeError
├── NoMatchingPatternError
├── ZeroDivisionError
├── NotImplementedError
├── SecurityError
├── SystemCallError
├── NoMethodError
└── NameError
| Method | Notes |
|---|---|
#message |
prelude/module.rs
| Method | Notes |
|---|---|
#include |
|
#ancestors |
prelude/class.rs
| Method | Notes |
|---|---|
#new |
creates a new instance |
#attr_reader |
|
#attr_writer |
|
#attr_accessor |
alias: attr |
#ancestors |
|
#inspect |
defined on the Module side |
prelude/integer.rs
| Method | Notes |
|---|---|
#[] |
bit reference |
#-@ |
unary minus |
#+ |
mixed arithmetic with Float |
#- |
mixed arithmetic with Float |
#** |
mixed arithmetic with Float |
#% |
|
#& |
bitwise AND |
#| |
bitwise OR |
#^ |
bitwise XOR |
#~ |
bitwise NOT |
#<< |
left shift |
#>> |
right shift |
#abs |
|
#to_i |
|
#to_f |
|
#chr |
|
#times |
takes a block |
#inspect |
alias: to_s |
#clamp |
prelude/float.rs
| Method | Notes |
|---|---|
#to_i |
|
#to_f |
|
#+ |
mixed arithmetic with Integer |
#- |
mixed arithmetic with Integer |
#* |
mixed arithmetic with Integer |
#/ |
mixed arithmetic with Integer |
#+@ |
unary plus |
#-@ |
unary minus |
#** |
mixed arithmetic with Integer |
#abs |
|
#inspect |
alias: to_s |
#clamp |
prelude/nilclass.rs
| Method | Notes |
|---|---|
#to_s |
returns "" |
#inspect |
returns "nil" |
#nil? |
returns true |
prelude/trueclass.rs
| Method | Notes |
|---|---|
#to_s |
alias: inspect |
#& |
|
#| |
|
#^ |
prelude/falseclass.rs
| Method | Notes |
|---|---|
#to_s |
alias: inspect |
#& |
|
#| |
|
#^ |
prelude/symbol.rs
| Method | Notes |
|---|---|
#to_s |
|
#inspect |
:sym format |
#to_proc |
converts symbol to a proc that calls the method |
prelude/proc.rs
| Method | Notes |
|---|---|
.new |
class method |
#call |
prelude/string.rs
| Method | Notes |
|---|---|
.new |
class method |
#+ |
string concatenation |
#* |
repetition |
#<< |
destructive append |
#[] |
alias: slice |
#[]= |
cf. slice! |
#b |
returns a binary (byte) string |
#clear |
|
#chomp |
|
#chomp! |
|
#dup |
|
#empty? |
|
#getbyte |
|
#setbyte |
|
#index |
|
#ord |
|
#slice |
|
#slice! |
|
#split |
|
#lstrip |
|
#lstrip! |
|
#rstrip |
|
#rstrip! |
|
#strip |
|
#strip! |
|
#to_sym |
alias: intern |
#start_with? |
|
#end_with? |
|
#include? |
|
#bytes |
|
#chars |
|
#upcase |
|
#upcase! |
|
#downcase |
|
#downcase! |
|
#to_i |
|
#to_f |
|
#unpack |
pack format: Q q L l I i S s C c |
#size |
alias: bytesize, length |
#inspect |
|
#to_s |
|
#=~ |
added by [feature: mruby-regexp] |
#!~ |
added by [feature: mruby-regexp] |
prelude/enumerable.rs
Included in Array, Hash, and Range.
| Method | Notes |
|---|---|
#map |
|
#find |
|
#select |
|
#all? |
|
#any? |
|
#delete_if |
|
#each_with_index |
|
#sort |
|
#sort_by |
|
#max |
|
#min |
|
#minmax |
|
#compact |
|
#count |
|
#to_a |
|
#uniq |
|
#reduce |
|
#sum |
prelude/array.rs
Includes Enumerable.
| Method | Notes |
|---|---|
.new |
class method |
#+ |
returns a new array containing elements from both arrays |
#push |
alias: << |
#[] |
alias: at |
#[]= |
|
#clear |
|
#delete_at |
|
#each |
|
#empty? |
|
#size |
alias: length |
#include? |
|
#& |
set intersection |
#| |
set union |
#first |
|
#last |
|
#pop |
|
#shift |
|
#unshift |
|
#dup |
|
#uniq! |
|
#map! |
|
#select! |
|
#reject! |
|
#sort! |
|
#sort_by! |
|
#pack |
format: Q q L l I i S s C c |
#inspect |
alias: to_s |
#join |
|
#flatten |
returns a new flattened array (recursive) |
#flatten! |
flattens self in place (recursive), returns self or nil |
prelude/hash.rs
Includes Enumerable.
| Method | Notes |
|---|---|
.new |
class method |
#[] |
|
#[]= |
|
#clear |
|
#dup |
|
#delete |
|
#empty? |
|
#has_key? |
|
#has_value? |
|
#key |
reverse lookup: value → key |
#keys |
|
#each |
block receives key and value |
#size |
alias: length, count |
#merge |
|
#merge! |
|
#to_h |
|
#values |
|
#inspect |
alias: to_s |
#flatten |
returns an array of [key1, value1, key2, value2, ...] |
prelude/range.rs
Includes Enumerable. Integer ranges only.
| Method | Notes |
|---|---|
#include? |
supports Integer and Float arguments |
#each |
Integer ranges only |
prelude/shared_memory.rs
A class for zero-copy sharing with WASM linear memory.
| Method | Notes |
|---|---|
.new |
takes a size in bytes |
#to_s |
|
#offset_in_memory |
alias: to_i — returns the memory offset (address) |
#[] |
range / index access |
#[]= |
|
#replace |
|
#read_by_size |
prelude/rand.rs
Uses the XorShift PRNG.
| Method | Notes |
|---|---|
.new |
seed is optional |
.rand |
class method |
.srand |
class method |
#rand |
instance method |
#seed |
returns the current seed |
Added to Kernel (Object):
| Method | Notes |
|---|---|
#rand |
uses the global default RNG |
prelude/regexp.rs
Uses the Rust regex crate.
| Method | Notes |
|---|---|
.new |
alias: .compile |
#=~ |
returns match position or nil |
#!~ |
|
#match |
returns a MatchData object |
#inspect |
| Method | Notes |
|---|---|
#[] |
capture group reference |
- Some arithmetic operators (
*,/) for Integer are not defined as instance methods in this prelude; they are handled directly by the VM bytecode interpreter (eval.rs). - Comparison operators (
<,<=,>,>=) are similarly handled on the VM side. String#=~and#!~are only added when[feature: mruby-regexp]is enabled.