Collection of MRuby sample programs (mirror)
- C 91.8%
- CMake 5.4%
- Ruby 2.8%
|
|
||
|---|---|---|
| .github/workflows | ci: Install SDL2 | |
| src | Add basic SDL2 example | |
| .clang-format |
Add Cpp11BracedListStyle and set it to false
|
|
| .clang-tidy | Add a clang-tidy configuration | |
| .editorconfig | Add header files to the same directives for C files | |
| .gitignore | Add more ignore directives | |
| CMakeLists.txt | Add basic SDL2 example | |
| LICENSE | Update copyright year | |
| README.md | README.md: Add C badge | |
MRuby Examples
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.