1
0
Fork
You've already forked mruby-examples
0
Collection of MRuby sample programs (mirror)
  • C 91.8%
  • CMake 5.4%
  • Ruby 2.8%
2026年02月24日 01:29:02 -03:00
.github/workflows ci: Install SDL2 2026年02月24日 01:22:01 -03:00
src Add basic SDL2 example 2026年02月24日 01:16:19 -03:00
.clang-format Add Cpp11BracedListStyle and set it to false 2024年11月03日 12:40:31 -03:00
.clang-tidy Add a clang-tidy configuration 2023年08月17日 20:08:52 -03:00
.editorconfig Add header files to the same directives for C files 2026年02月16日 00:42:52 -03:00
.gitignore Add more ignore directives 2026年02月22日 15:18:24 -03:00
CMakeLists.txt Add basic SDL2 example 2026年02月24日 01:16:19 -03:00
LICENSE Update copyright year 2024年03月11日 22:18:26 -03:00
README.md README.md: Add C badge 2026年02月24日 01:29:02 -03:00

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 build
cmake --build build

Summary

Examples included here:

Basic

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.

SDL2

Example Description
sdl-wrapper Basic 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.