Collection of MRuby sample programs.
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
Use the followings commands
cmake -S . -B build
cmake --build build
Examples included here:
Example | Description |
---|---|
hello-world | Classic hello world. |
hello-file | Load and execute Ruby code from a file. |
pushing-variables | Define various types of variables from C to Ruby. |
objects | Create classes & objects from C. |
method-defined | Check if a certain method is defined on Ruby. |
call-methods | Call Ruby methods from C. |
using-cdata | Wrap C data inside a Ruby object. |
kwargs | Parse keyword arguments. |
blocks | Interact with Ruby's block from C. |
compiling-bytecode | Compile Ruby code into bytecode format and save it on the disk. |
Credits where due, here are some helpful articles/post/resources that helped me to learn how to use MRuby:
All the examples found here are licensed under the MIT license.