Skip to content

Repository files navigation

MRuby Examples

C

Collection of sample MRuby programs.

Build

Get MRuby

Make sure you've got MRuby installed, see here.

Tip

If you are on Linux chances are MRuby is already in the package repositories of your favorite distro! then you'll need to use your distro specific package manager to install it. E.g:

APT:

sudo apt install libmruby-dev

DNF:

sudo dnf install mruby-devel

Pacman:

sudo pacman -S mruby

Other requirements

Some examples require SDL2. Install it:

$ sudo apt install libsdl2-dev

or

$ sudo dnf install SDL2-devel

Compiling

Use the followings commands:

cmake -S . -B buildcmake --build build

Summary

Examples included here:

Basic

ExampleDescription
hello-worldClassic hello world.
hello-fileLoad and execute Ruby code from a file.
pushing-variablesDefine various types of variables from C to Ruby.
objectsCreate classes & objects from C.
method-definedCheck if a certain method is defined on Ruby.
call-methodsCall Ruby methods from C.
using-cdataWrap C data inside a Ruby object.
kwargsParse keyword arguments.
blocksInteract with Ruby's block from C.
compiling-bytecodeCompile Ruby code into bytecode format and save it on the disk.

SDL2

ExampleDescription
sdl-wrapperBasic wrapper around SDL2 to create a window.

Credits

Credits where due, here are some helpful articles/post/resources that helped me to learn how to use MRuby:

License

All the examples found here are licensed under the MIT License.

About

Collection of sample MRuby programs

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Contributors

Languages